*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 ‘�PNG
‘.*
if i remove the <asp:updatepanel its all working fine
protected void gvFiles_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Download")
{
byte[] byteArray = item.AttachContent.ToArray();
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + item.AttachFileName + "\"");
Response.AppendHeader("Content-Length", byteArray.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(byteArray);
Response.End();
}
}
This is occurring because you are trying to do a
Response.BinaryWrite.You get this error because because you are trying to return non HTML to the
UpdatePanelusing an asynchronous callback which is not allowed. The only thing I can suggest is to try using aPostBackTriggerand targetting a control outside of yourUpdatePanel.The best solution would be to make you download button spawn another window that calls an
.ashx(generic handler) and server up the binary via the ashx. You can just attach a javascript function to handle the click which will open a new window to the ashx with whatever params are needed passed in.This link has more information on the exact problem and ways of solving it.