Recently I’ve had more and more pages displaying unexpected behaviour.
I had an UpdatePanel with a button inside it. The button’s Click event performed a Response.Redirect(), but nothing happened.
The Javascript error console showed the following error message:

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 Response.Write(), response filters, HttpModules, or server trace is enabled.

After some googling it seems that ASP.Net doesn’t quite support Response.Redirect() inside UpdatePanels any more.

The solution was to make sure the button actually performed a full postback of the webpage, and not only a partial postback (as it would do because it was inside an UpdatePanel).

There are two ways of doing this. First the easy way:

<asp:UpdatePanel runat="server">
    <asp:Button ID="MyButton" runat="server" />
    <asp:PostBackTrigger ControlID="MyButton" />

Here you’re basically telling the UpdatePanel that “MyButton” should perform a full postback instead of a partial one.
My problem was a bit more complicated, though, because “MyButton” was inside a GridView. This complicated things a bit, but not too much. Mainly you have to have access to the ScriptManager.

Add the OnRowDataBund event to your GridView. In this event do the following:

protected void MyGridview_RowDataBound(object sender, GridViewRowEventArgs e)
  if (e.Row.RowType == DataControlRowType.DataRow)
    Button MyButton = (Button)e.Row.FindControl("MyButton");

So instead of telling the UpdatePanel that your button should do a full postback, you’re telling the ScriptManager the same thing.

Doing this in code-behind would obviously work for the first example as well.


This seems to be a recurring bug in .Net 2.0, 3.0 and 3.5, and is actually fixed in .Net 4.x.
I have successfully got a Response.Redirect() to work inside an update panel without using any of the above fixes, and only by upgrading my solution, projects and website to .Net 4.0.