用客户端脚本,判断错误类型,如果出现这种错误,自动reload: 
使用ScriptManager的EndRequestHandler事件。将以下Javascript加入到 <ScriptManager> 标签后面, 注意不能放在 <Head> 中。 
程序代码 <script language= "javascript "> Sys.WebForms.PageRequestManager.getInstance().add_endRequest (EndRequestHandler); 
function EndRequestHandler(sender, args) 

if (args.get_error() != undefined) 

if(args.get_error().message.substring(0, 51) == "Sys.WebForms.PageRequestManagerParserErrorException ") 

window.location.reload(); //出现Session丢失时的错误处理,可以自己定义。 

else 

alert( "发生错误!原因可能是数据不完整,或网络延迟。 "); //其他错误的处理。 

args.set_errorHandled(true); 


</script> 但愿能解决你的问题。 
************************************ 
在if(args.get_error()。语句位置,
加上alert(args.get_error().message); 
看一下捕获的错误信息是什么。

解决方案 »

  1.   

    Ajax是无刷新的,而使用Response进行带参重定向时需要刷新页面。所以只须在UpdatePanel下设置“asp:PostBackTrigger”的“ControlID”为指定的控件名称即可,如:
    <Triggers>
    <asp:PostBackTrigger ControlID="btnSave" />
    </Triggers>
    参考一下:http://www.cnblogs.com/dongyongjing/archive/2007/03/20/681411.html
      

  2.   

    还是不行,我的后台代码是这样的protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = this.txtUserName.Text.Replace("'", "").Trim();
            string password = this.txtPassword.Text.Replace("'", "").Trim();
            User user = UserManager.ValidateUser(userName, password);
            if (user != null)
            {
                this.lblUserName.Text = user.UserName;
                Session["CurrentUser"] = user;
                this.divUserInfo.Style.Add("display", "none");
                this.divWelcome.Style.Add("display", "block");
                this.txtUserName.Text = "";
                this.txtPassword.Text = "";
            }
            else
            {
                ScriptManager.RegisterStartupScript(btnLogin, this.GetType(), "",
                    "alert('您输入的用户名或密码错误!')", true);
                this.txtUserName.Text = "";
                this.txtPassword.Text = "";
            }
        }
      

  3.   

    ScriptManager.RegisterStartupScript(btnLogin, this.GetType(), "", 
                    "alert('您输入的用户名或密码错误!')", true); 
    改成:
    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", "alert('您输入的用户名或密码错误');", true);