c# ajax
the message received from the server could not be parsed
在updatepanle里面包含了一个gridview,经常不时的出现这个错误the message received from the server could not be parsed!查了晚上的资料发现了原因。updatepanle里的是异步的,而我在里面加了一个linkbutton,并且单击时,里面写了response.redirect();这样会postback。。因而引发异常! 于是把response.redirect 改用脚本弹出窗口,就没问题了!
Code
string script = "window.open('" + url + "');";
Page page = (Page)Context.Handler;
ScriptManager.RegisterStartupScript(page, typeof(Page), "RedirectTo", script, true);
引用页面:
http://www.dalun.com/blogs/08.13.2007.htm
string script = "window.open('" + url + "');";
Page page = (Page)Context.Handler;
ScriptManager.RegisterStartupScript(page, typeof(Page), "RedirectTo", script, true);

本文详细介绍了在使用ASP.NET MVC框架时,如何避免在异步更新面板中添加链接按钮并触发重定向时产生的解析错误。通过将重定向操作替换为JavaScript脚本弹出窗口,可以有效防止页面重新加载导致的问题。
2780

被折叠的 条评论
为什么被折叠?



