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

时间:2008-10-07 12:20:11  来源:第二电脑网上收集  作者:

  第二电脑网导读:quot;,this) ;  2.上面用到的CommonScript类里的MessageBox方法:public static void MessageBox(string str_ErrCode, Page page) ...
  正文:

如果你不喜欢JavaScript的alert那种单调的对话框,可以用这种自定义的方法.

  

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.RegisterStartuphotoshop/ target=_blank class=infotextkey>pscript("","<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

ASP.NET中自定义提示对话框》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/ASP/2008-10-07/3397.html


关键字:

关于《ASP.NET中自定义提示对话框》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td