with the only difference that I put a linkbutton at the footer of the GridView which is inside an update panel for ajax, when I try to export the GridView I get this error:
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 '<div>
<table class'.
Well what I found is that if I put the Export file button outside the update Panel it works just fine. Why is that? is there a way to avoid that error.
Im trying to do that but, I have a big issue, the ScriptManager control is in a Master Page, so I tried:
this.Master.FindControl("ScriptManager").RegisterPostBackControl(btnExport); but it doesnt compile because it says that System.Web.UI.Control does not contain a definition for RegisterPostBackControl.
Ok I managed to handle that problem above(just declared a ScriptManager and that did the job), but now I have another issue, GridView is not Binded at Page_Load, so when I try: sM.RegisterPostBackControl(this.GridView1.FindControl("btnExport")); it will
throw an exception Value cannot be null. so, can I register somewhere else? how can I do this? or just forget to have it inside the GridView and place the linkbutton outside?
ceschamo
Member
9 Points
42 Posts
Microsoft JScript runtime error
Aug 20, 2009 10:42 PM|LINK
hello all, I have the following situation, I have a Gridview and Im trying to export it to an excel File with this code: http://www.highoncoding.com/Articles/197_Extensive%20Study%20of%20GridView%20Export%20to%20Excel.aspx
with the only difference that I put a linkbutton at the footer of the GridView which is inside an update panel for ajax, when I try to export the GridView I get this error:
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 '<div>
<table class'.
Well what I found is that if I put the Export file button outside the update Panel it works just fine. Why is that? is there a way to avoid that error.
Thanks
maverickhyd
Contributor
2718 Points
503 Posts
Re: Microsoft JScript runtime error
Aug 21, 2009 12:55 PM|LINK
Hi,
Export(Download) causes Response.write on form for that postback is required.so you have to registered the Link button as a postback control
Add this code In Page_Load
ScriptManager1.RegisterPostBackControl(linkButtonId);
ceschamo
Member
9 Points
42 Posts
Re: Microsoft JScript runtime error
Aug 21, 2009 05:59 PM|LINK
Hello,
Im trying to do that but, I have a big issue, the ScriptManager control is in a Master Page, so I tried:
this.Master.FindControl("ScriptManager").RegisterPostBackControl(btnExport); but it doesnt compile because it says that System.Web.UI.Control does not contain a definition for RegisterPostBackControl.
any thoughts?
ceschamo
Member
9 Points
42 Posts
Re: Microsoft JScript runtime error
Aug 21, 2009 07:50 PM|LINK
Ok I managed to handle that problem above(just declared a ScriptManager and that did the job), but now I have another issue, GridView is not Binded at Page_Load, so when I try: sM.RegisterPostBackControl(this.GridView1.FindControl("btnExport")); it will throw an exception Value cannot be null. so, can I register somewhere else? how can I do this? or just forget to have it inside the GridView and place the linkbutton outside?
please advice, Thanks
maverickhyd
Contributor
2718 Points
503 Posts
Re: Microsoft JScript runtime error
Aug 22, 2009 06:13 AM|LINK
Hi,
Yes Obviously It will give null because Data is not binded to the gridview
You Should keep in Mind these Points
After Binding the Data You Have to register because your control is under Gridview
For every postback you have to register i.e
sM.RegisterPostBackControl(this.GridView1.FindControl("btnExport"));
ceschamo
Member
9 Points
42 Posts
Re: Microsoft JScript runtime error
Aug 24, 2009 04:38 PM|LINK
Hi,
I tried Registering it after Binding the Data but still getting this error:
Value cannot be null. Parameter name: control
but whats is failing here is actually: this.GridView1.FindControl("btnExport"), its not finding the control and thats why I cannot register it...
What I tried after realizing this, was registering it but on the Row_Command method and getting the linkbuttong like this:
LinkButton btnExport = (LinkButton)e.CommandSource;
then I register it but I get back to the original issue, the Microsoft JScript runtime error.
ceschamo
Member
9 Points
42 Posts
Re: Microsoft JScript runtime error
Aug 25, 2009 04:27 PM|LINK
Hi, I resolved the problem finding the control, the control was at the footer so by using
(LinkButton)this.GridView1.FooterRow.FindControl("btnExport");
after that I was able to register the control and its working now,
thanks for your help