zoukankan      html  css  js  c++  java
  • 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作为参数,这样脚本才能起作用。


  • 相关阅读:
    认证功能装饰器
    装饰器升级版
    装饰器
    闭包函数
    名称空间与作用域
    嵌套函数
    函数对象
    命名关键字参数
    函数单数的使用
    函数的定义与调用
  • 原文地址:https://www.cnblogs.com/lavenderzh/p/1036891.html
Copyright © 2011-2022 走看看