2012年3月26日月曜日

Response.Redirect in a PostBack causes javascript error => workaround here

There's a problem in Atlas when calling a Response.Redirect on a postback (and the ScriptManager uses "EnablePartialRendering=true"). E.g. doing a Response.Redirect("otherpage.aspx") from the button-click event code.

There's a workaround, however.

Instead of doing:

Response.Redirect("otherpage.aspx");

do this:

Page.ClientScript.RegisterStartupScript(
this.GetType(), "redirect",
"window.location.href='otherpage.aspx';",true);

I wrote a custom httpmodule (acquirerequeststate event) that needed to do a response.redirect in certain cases. This threw the "unknown error" on atlas pages. I added "false" for the endReponse parameter and it works fine now. Response.Redirect("page.aspx",false).

thanks

0 件のコメント:

コメントを投稿