当前位置导航:炫浪网>>网络学院>>网页制作>>ASP.NET教程

ASP.NET中自定义提示对话框

欢迎进入.NET社区论坛,与200万技术人员互动交流 >>进入1.在需要的地方调用下面的方法:  CommonScript.MessageBox("100006",this) ;   2.上面用到的CommonScript类里的MessageBox方法:  public static void MessageBox(string str_ErrCode, Page page)             {                   IDataReader ErrMsg= DatabaseAccess.executeDataReader("ImportAndExport","Select ErrMessage from ErrMessage where ErrCode='" + str_ErrCode + "'");                   while (ErrMsg.Read())                   {                         String ErrMessage=ErrMsg["ErrMessage"].ToString();                         page.RegisterStartupScript("","<script>alert('"+ ErrMessage +"');</script>");                         break ;                   }             } 3. 上面用到的DatabaseAccess类里的executeDataReader方法  public static IDataReader executeDataReader(String connectionString, String Sqlstr )             {                    Database db= DatabaseFactory.CreateDatabase(connectionString);                   IDataReader dr;                   DBCommandWrapper wrap = db.GetSqlStringCommandWrapper(Sqlstr);                   dr=db.ExecuteReader(wrap);                   return dr;             } 4.上面用到的连接串ImportAndExport在dataconfiguration.config里的内容(粗体部分):  <?xmlversion="1.0"encoding="utf-8"?> <dataConfiguration>  <xmlSerializerSectiontype="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null">     <enterpriseLibrary.databaseSettingsxmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"defaultInstance="ImportAndExport"xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">       <databaseTypes>         <databaseTypename="Oracle Database"type="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null"/>         <databaseTypename="Sql Database"type="Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null"/>       </databaseTypes>       <instances>         <instancename="EA21SG3T"type="Oracle Database"connectionString="EA21SG3T"/>         <instancename="ImportAndExport"type="Sql Database"connectionString="ImportAndExport"/>         <instancename="Sql Instance"type="Sql Database"connectionString="Sql Connection String"/>       </instances>       <connectionStrings>         <connectionStringname="ImportAndExport">           <parameters>             <parametername="data source"value="192.168.1.59"isSensitive="false"/>             <parametername="database"value="ImportAndExport"isSensitive="false"/>             <parametername="pwd"value="sa"isSensitive="false"/>             <parametername="uid"value="sa"isSensitive="false"/>           </parameters>         </connectionString>         <connectionStringxsi:type="OracleConnectionStringData"name="EA21SG3T">           <parameters>             <parametername="data source"value="EA21SG3T"isSensitive="false"/>             <parametername="Password"value="developer"isSensitive="false"/>             <parametername="User Id"value="developer"isSensitive="false"/>           </parameters>           <packages/>         </connectionString>         <connectionStringname="Sql Connection String">           <parameters>             <parametername="data source"value="192.168.1.59"isSensitive="false"/>             <parametername="database"value="ImportAndExport"isSensitive="false"/>             <parametername="pwd"value="sa"isSensitive="false"/>             <parametername="uid"value="sa"isSensitive="false"/>           </parameters>         </connectionString>       </connectionStrings>     </enterpriseLibrary.databaseSettings>  </xmlSerializerSection> </dataConfiguration>   5.数据库:  if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ErrMessage]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[ErrMessage] GO   CREATE TABLE [dbo].[ErrMessage] (       [ErrID] [int] NOT NULL ,       [ErrCode] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,       [ErrModul] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,       [ErrSubModul] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,       [ErrMessage] [nvarchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ) ON [PRIMARY] GO
相关内容
赞助商链接