一般的弹出对话框会使页面丢失css样式,采用下面方法可以解决。
    /// <summary>
    /// 弹出对话框,并不影响css样式
    /// </summary>
    /// <param name="page"></param>
    /// <param name="scriptKey">脚本键值,必须唯一</param>
    /// <param name="message">显示的消息内容</param>
 
    public static void ShowMessage(System.Web.UI.Page page, string scriptKey, string message)
    {
        System.Web.UI.ClientScriptManager csm = page.ClientScript;
        System.Text.StringBuilder strScript = new System.Text.StringBuilder();
        if (!csm.IsClientScriptBlockRegistered(scriptKey))
        {
            strScript.Append("alert('");
            strScript.Append(message);
            strScript.Append("');");

            csm.RegisterClientScriptBlock(page.GetType(), scriptKey, strScript.ToString(), true);
        }
    }

posted on 2008-06-17 13:56  朱胜  阅读(690)  评论(0编辑  收藏  举报