日期:2014-05-17  浏览次数:20560 次

关于弹出对话框的问题
用了一个弹出对话框的类,但是遇到了一个郁闷的问题,问题就在window.alert('" + strMsg + "');这句上,弹出对话框后页面一片白,加了history.back()也不行,还是一片白,为什么不能像ASP那样后退回原页面呢?另外顺便问一下System.Web.UI.Page page这个参数我应该怎么赋值呢?

    public class ShowMessage
    {
        public ShowMessage()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        public static void ShowMsg(string strMsg)
        {
            System.Web.HttpContext.Current.Response.Write("<Script Language='JavaScript'>window.alert('" + strMsg + "');history.back();</script>");
        }
        public static void ShowMsg(System.Web.UI.Page page, string strMsg)
        {
            page.Response.Write("<Script Language='JavaScript'>window.alert('" + strMsg + "');</script>");
        }
        public static void ShowMsg(string strMsg, string Url)
        {
            System.Web.HttpContext.Current.Response.Write("<Script Language='JavaScript'>window.alert('" + strMsg + "');window.location.href ='" + Url + "'</script>");
        }
        public static void ShowMsg(System.Web.UI.Page page, string strMsg, string Url)
        {
            page.Response.Write("<Script Language='JavaScript'>window.alert('" + strMsg + "');window.location.href ='" + Url + "'</script>");
        }
        public static void ShowConfirm(string strMsg, string strUrl_Yes, string strUrl_No)
        {
            System.Web.HttpContext.Current.Response.Write("<Script Language='JavaScript'>if ( window.confirm('" + strMsg + "')) {  window.location.href='" + strUrl_Yes +
                              "' } else {window.location.href='" + strUrl_No + "' };</script>");
        }
    }

------解决方案--------------------
ShowMsg你是在页面后台调用的吧,所以System.Web.UI.Page page参数传this即可