Add this to the Page_Load () method.
Assuming ibtGenerateReport is your button
protected void Page_Load(object sender, EventArgs e) { ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page); scriptManager.RegisterPostBackControl(this.ibtGenerateReport);
Explanation:
The UpdatePanel control uses asynchronous callbacks to control which parts of the page will be displayed. He does this using a whole bunch of JavaScript on the client and a whole bunch of C # on the server. This is output using a special format that JavaScript can understand on the client. If you ruin the format by rendering things outside the page rendering phase, the format will be ruined.
Why do I keep getting a PageRequestManagerParserErrorException?
Well, most likely you are doing one of the things mentioned in the error message. Here are the most common reasons and why they do not work:
Calling Response.Write (): By calling the Response.Write () function directly, you bypass the regular ASP.NET control rendering mechanism. The bits you write go directly to the client without further processing.
Response Filters / HttpModules: Like Response.Write (), they can change the rendering in such a way that the UpdatePanel will not know.
Server tracing is enabled: Tracing is efficiently written using Response.Write (), and as such will ruin the special format that we use for UpdatePanel.
Calls to Server.Transfer (): Unfortunately, there is no way to detect that Server.Transfer () has been called. This means that UpdatePanel cannot do anything smart when someone calls Server.Transfer (). The response sent to the client is the HTML markup from the page you went to. Since its HTML, and not a special format, it cannot be parsed and you will get an error.
Solution: One way to avoid a parsing error is to make a regular postback instead of asynchronous postback by calling ScriptManager.RegisterPostBackControl ()
Please refer to the full Explained and other solutions from the Ellon Lipton blog here.