当前位置: 代码迷 >> ASP.NET >> aspx.cs顶用Response.Write打印alert
  详细解决方案

aspx.cs顶用Response.Write打印alert

热度:3455   发布时间:2013-02-25 00:00:00.0
aspx.cs中用Response.Write打印alert
很简单的一个问题,我要在catch语句块中要通过Response.Write方法打印出捕获的异常:
catch (Exception exp)
{
  string expMsg = exp.ToString();
  Response.Write("<Script> alert(...) </script> ");
}

里面的Script语句应该怎么写呢?

------解决方案--------------------------------------------------------
ClientScript.RegisterStartupScript(this.GetType(), "message", "<script language='javascript'>alert('" + ex.Message+ "');</script>");

------解决方案--------------------------------------------------------
Response.Write("<Script> alert('" + exp.ToString() + "'); </script> ");
改成Response.Write("<script> alert('" + exp.ToString() + "'); </script> ");
js区分大小写
  相关解决方案