Asp.net 中弹出窗口

在要弹出窗口的页面对应的cs里放置下面代码:

StringBuilder msg = new StringBuilder();
                msg.Append("Error: ");
                msg.Append(“错误内容!”);
                msg.Replace("/r/n","");
               
                //Response.Write("<script>alert(/""+msg.ToString()+"/")</script>");
                StringBuilder strScript = new StringBuilder();
                strScript.Append("<script language = /"javascript/">");
                strScript.Append("/n");
                strScript.Append("function ShowMsg(msg)/n");
                strScript.Append("{");
                strScript.Append("thisWin = window.open(/"/", null, /"width=300,height=400/");/n");
                strScript.Append("thisWin.document.write(/"<head><title></title></head>/");/n");
                strScript.Append("thisWin.document.write(/"<body>/"+msg+/"</body>/");/n");
                strScript.Append("}/n");
                strScript.Append("</script>/n");
                if (!Page.ClientScript.IsClientScriptBlockRegistered("ShowExceptionMsg"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ShowExceptionMsg", strScript.ToString());
                }
                this.divShowWindow.InnerHtml=("<script>" + "ShowMsg(/""+ msg +" /")" + "</script>"); 

在网页上放置一个div标签 id=divShowWindow,当条件执行时会看到有个错误窗口弹出,如果不用此种方法

可以用js里内置函数alert()同样可以,如果不用控件也不用alert则总会有错误发生,原因是:...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值