I am using Visual Studio 2008. I have a default.aspx page that has an AJax Update Panel on it with a datagrid inside it. The datagrid has a LinkButton column and when the user clicks the data, the code behind does a Response.Redirect("myPage.aspx", true);
I get this error message after the Page_Load of the myPage fires. If I take the Update Panel off the default.aspx page, then it runs with no problems. Is there any solutions to keeping the update panel on the webpage and doing a response.redirect? The full
error message is this.
Microsoft JScript runtime error: 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.
Details: Error parsing near '
The AJAX UpdatePanel requires a return that is un-filtered by any HttpModule or HttpHandler. Since the Response object uses an HttpHandler to handle the HttpResponse, the UpdatePanel will fire the error you see as a security precaution. (Imagine if I was
to deploy a HttpHandler to my server that injected some Javascript or SQL injection into the partial post. .... nasty thought huh?)
What you can do is add the btn as a PostBackTrigger. However, there's a caveat in that the LinkButton is inside the GridView so we have to do a bit of a work-around. Please check:
may I ask how this Response.Redirect code gets executing? Button click event? And also is the control that makes it execute in the update panel? if so make that true into a false and see if that helps.
Then, trying to follow that other post,where he said to
'in the html markup you need to add the following to the template button properties: add OnPreRender="addTrigger_PreRender"
There isn't a OnPreRender to either the asp:templateColumn or hte ItemTemplate so I added it the DataGrid, because that is the only place I could find an OnPreRender.
AsyncPostBackTrigger is incorrect. It's actually required to be a PostBackTrigger. This is because we *don't want a partial postback; we are redirecting to a new execution thread*.
The idea is that on the linkbutton's PreRender event we're adding the NewScriptManager.RegisterPostBackControl(MyButton) -- there's no need to set it declaritively in the ASPX page, it won't find it anyway and will throw a runtime error because the LinkButton
is inside a databound templated control.
If this post helped you, Mark As Answer.
Marked as answer by cpaschen on Mar 05, 2009 11:44 AM
auto complete extender worked normally but when i click to button then i get message in script resources
Microsoft JScript runtime error: 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.
Details: Error parsing near '=========758|updateP'.
if i use button is outside the panel it works.
but i want to use button with update panel its my requirement
cpaschen
Member
23 Points
23 Posts
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could n...
Mar 04, 2009 04:29 PM|LINK
I am using Visual Studio 2008. I have a default.aspx page that has an AJax Update Panel on it with a datagrid inside it. The datagrid has a LinkButton column and when the user clicks the data, the code behind does a Response.Redirect("myPage.aspx", true); I get this error message after the Page_Load of the myPage fires. If I take the Update Panel off the default.aspx page, then it runs with no problems. Is there any solutions to keeping the update panel on the webpage and doing a response.redirect? The full error message is this.
Microsoft JScript runtime error: 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.
Details: Error parsing near '
<!DOCTYPE html P'.
Thanks
Christel
jpuckett
Contributor
5802 Points
1036 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
Mar 04, 2009 06:30 PM|LINK
The AJAX UpdatePanel requires a return that is un-filtered by any HttpModule or HttpHandler. Since the Response object uses an HttpHandler to handle the HttpResponse, the UpdatePanel will fire the error you see as a security precaution. (Imagine if I was to deploy a HttpHandler to my server that injected some Javascript or SQL injection into the partial post. .... nasty thought huh?)
What you can do is add the btn as a PostBackTrigger. However, there's a caveat in that the LinkButton is inside the GridView so we have to do a bit of a work-around. Please check:
http://forums.aspfree.com/net-development-11/gridview-footer-template-button-in-updatepanel-not-posting-back-236087.html
for info on how they did it.
Omego2K
Member
344 Points
198 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
Mar 04, 2009 06:32 PM|LINK
may I ask how this Response.Redirect code gets executing? Button click event? And also is the control that makes it execute in the update panel? if so make that true into a false and see if that helps.
cpaschen
Member
23 Points
23 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
Mar 04, 2009 07:09 PM|LINK
OK, so I read that other post on how to add the butotn as a PostBackTrigger but I'm confused. I added
<
Triggers> <asp:AsyncPostBackTrigger ControlID="dgArrestByCrimes" EventName="ItemCommand" /> </Triggers>to the update panels trigger.
Then, trying to follow that other post,where he said to
'in the html markup you need to add the following to the template button properties: add OnPreRender="addTrigger_PreRender"
There isn't a OnPreRender to either the asp:templateColumn or hte ItemTemplate so I added it the DataGrid, because that is the only place I could find an OnPreRender.
Then in code behind I added this
protected void addTrigger_PreRender(object sender, EventArgs e){
if (sender is LinkButton){
LinkButton MyButton = (LinkButton)sender;ScriptManager NewScriptManager = (ScriptManager)this.FindControl("ScriptManager1");NewScriptManager.RegisterAsyncPostBackControl(MyButton);
this.ScriptManager1.RegisterAsyncPostBackControl(MyButton);}
}
But this doesn't work. Can you tell me what I did wrong?
jpuckett
Contributor
5802 Points
1036 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
Mar 05, 2009 04:19 AM|LINK
AsyncPostBackTrigger is incorrect. It's actually required to be a PostBackTrigger. This is because we *don't want a partial postback; we are redirecting to a new execution thread*.
The idea is that on the linkbutton's PreRender event we're adding the NewScriptManager.RegisterPostBackControl(MyButton) -- there's no need to set it declaritively in the ASPX page, it won't find it anyway and will throw a runtime error because the LinkButton is inside a databound templated control.
cpaschen
Member
23 Points
23 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
Mar 05, 2009 11:43 AM|LINK
I changed it to the PostBackTrigger and it works beautifully. I can't thank you enough!!!
Chit Min Mau...
Member
79 Points
77 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
Apr 07, 2010 01:09 AM|LINK
Hi jpuckett,
Can I ask you a few? I also have encountered this problem. I can't find any solution on web.
http://forums.asp.net/t/1542142.aspx Here is my question.
I just want to know ... I used gridview and I have already populated the attachment information in this grid.
After thant I just want to when I click uploaded file name in second column, this file will download... like this...
so... in this grid i also used delete button in one row, one button... it is okay... but my download link didn't work... I can't understand.
pls help if you are okay...
MCTS/ MCP
Analyst Programmer
http://www.cmmaung.me/
If this post helped you, please mark as Answer.
TajKhan
Participant
1747 Points
437 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
May 25, 2010 05:58 PM|LINK
Hello
I am getting the same error but i did'nt find any solution yet..
You can refer my post here
http://forums.asp.net/t/1561263.aspx
Ali Asgar
imranm
Member
12 Points
7 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
Aug 21, 2010 08:14 AM|LINK
i am using autocomplete extender with updatepanel
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate >
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged" AutoPostBack ="true" ></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID ="TextBox1" CompletionInterval="250" MinimumPrefixLength="1" FirstRowSelected ="true" ServicePath="Nationality.asmx" ServiceMethod="GetCountryInfo" CompletionSetCount="15">
</cc1:AutoCompleteExtender>
<asp:TextBox ID="TextBox2" runat="server" ontextchanged="TextBox2_TextChanged" AutoPostBack ="true"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" TargetControlID ="TextBox2" CompletionInterval="250" MinimumPrefixLength="1" FirstRowSelected ="true" ServicePath="Nationality.asmx" ServiceMethod="GetStateInfo" CompletionSetCount="15" UseContextKey ="true" >
</cc1:AutoCompleteExtender>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender3" runat="server" TargetControlID ="TextBox3" CompletionInterval="250" MinimumPrefixLength="1" FirstRowSelected ="true" ServicePath="Nationality.asmx" ServiceMethod="GetCityInfo" CompletionSetCount="15" UseContextKey ="true" >
</cc1:AutoCompleteExtender>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>auto complete extender worked normally but when i click to button then i get message in script resources
Microsoft JScript runtime error: 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.
Details: Error parsing near '=========758|updateP'.
if i use button is outside the panel it works.
but i want to use button with update panel its my requirement
imranm
Member
12 Points
7 Posts
Re: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server cou...
Aug 21, 2010 08:24 AM|LINK
error image