Problem
When you are modifying Response with Response.Write() from control which is inside UpdatePanel you may receive an error "Message received from the server could not be parsed"
Solution
Solution is to add a trigger to UpdatePanel like this:
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnExportToExcel" />
</Triggers>
</asp:UpdatePanel>
This causes an UpdatePanel to refresh the page only in control specified in Triggers section
Thank you!!!
ReplyDeleteOne question,though... My button is inside a grid view (ItemTemplate). ASP.net says it can't find it. I verified the ID, etc. Any ideas?
ReplyDeleteyou cant directly access the controls in grid views, for that you have to loop through the grid view and find control like
Deletefor(int i=0;i<myGridView.Rows.Count;i++)
{
Button btnAdd=(Button)myGridView.Rows[i].FindControl("btnID");
}
or you can access the button by going to the click event of the button which is inside the grid view like this
btn_Click()
{
Button btnAdd=(Button)sender;
}
Regards:
Mudassir
You can use the UniqueID field of the button.
ReplyDeleteThanks man. saved me hours of headaches.
ReplyDeleteThank you very much!!!!!
ReplyDeleteHi to all.I have the same problem.I tried all,and still not result.Here is my code.
ReplyDeleteDim buf As Byte() = get_byte()
Page.Response.Clear()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-disposition", "attachment; filename=Statment.pdf")
Response.BinaryWrite(buf)
Response.End()
My get_byte()function works fine. Can anybody help me?
I recieve following message
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 '%PDF-1.4
%??2 0 obj '.
My btn_ExportPdf is in updatepanel and I also add triggers tag like this
Please,help...thanks in advanced :)
like this
ReplyDeleteLIFE SAVER
ReplyDeleteNice! Also if you can give an explaination as why is this working..
ReplyDeleteThanks!
The best solution so far.
ReplyDeleteThanks.
Thanks dear
ReplyDeletebut its working
thank you bro..its working for me
ReplyDeleteGreat solution. Love the simplicity.
ReplyDeleteThis code works for me where I was attempting to return a PDF.
.. and the ASCX page contained the gridview.
FYI: Used the Triggers / PostBackTrigger code with
Deleteasp:PostBackTrigger ControlID="IDofAscxPageReference"
and the ASCX page contained the gridview.
if (!Page.IsPostBack)
ReplyDelete{
Response.Output.Write("Bla Bla Bla");
}
Gracias!! me sirvio mucho
ReplyDelete