我经常在vs2005的cs文件里写 Response.Write("<script>alert('');</script>");这样的语句。但是在vs2008中使用就老报错。
错误:Sys.WebForms.PageRequestManagerParserErrorException:无法分析从服务器收到的消息。之所以出现此问题,常见的原因是在通过调用Response.Write()修改相应时,将启用相应筛选器、HttpModule或服务器跟踪。

解决方案 »

  1.   

    Response.Write("<script>alert('Hello');</script>");
    可以正常使用的呀,没有问题
      

  2.   

    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "message", string.Format("<script>alert(\"{0}\")</script>", "")); 
      

  3.   

    Response.Write(" <script>alert(''); </script>");这写法不好,因为Response.Write会直接输出到网页源码的顶部,有时会破坏的样式最好用RegisterStartupScript是向客户端输出脚本,比Response.Write好在把脚本输入在网页最下面,不会影响样式,但是有时VS2005会提示一个长长的警告,解决方法是写成:ClientScript.RegisterStartupScript(this.GetType(), "", "<script language=javascript>alert('请先保存修改内容!')</script>");可以参考我的空间:
    http://hi.baidu.com/mytot/blog/item/9ea4e20efd07bee137d122ea.html