您的位置:首页 > 其它

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

2008-01-13 12:27 561 查看
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作为参数,这样脚本才能起作用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐