• AJAX使用了UpdatePanel后无法使用alert弹出脚本


    AJAX中使用了UpdatePanel后不能再使用Response.Write("<script>alert('11')</script>")的方式弹出脚本,而应该使用
     Microsoft.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "btn2clicked", "alert('11')", true);
    否则,将会出现如下错误:

    Sys.WebForms.PageRequestManagerParserErrorException:
    The message received from the server could not be parsed . Common causes for this error are when the response is modified by calls to Responsed.Write(),response filters,HttpModules, or server trace is enabled.
    Details:Error parsing near' <script> alert('sss'.

    另外,需要注意的是第一个参数是UpdatePanel的实例,如果在页面中有多个UpdatePanel,如果每个UpdatePanel的UpdateMode都是“always”[默认值]的话,那么你使用那个UpdatePanel的实例作为参数都可以;如果每个UpdaePanel的UpdateMode=conditional,那么你必须使用正在更新的那个UpdatePanel作为参数,这样脚本才能起作用。


  • 相关阅读:
    Hbase安装与简单使用
    Integer Int
    Maven是什么
    对Servlet执行流程的初步认识
    android studio 开发环境的搭建
    centos下更换默认的python版本
    写出我心(七)
    写出我心(六)
    写出我心(五)
    写出我心(四)
  • 原文地址:https://www.cnblogs.com/lavenderzh/p/1036891.html
Copyright © 2020-2023  润新知