show pdf with bytestream in an updatepanel
I want to send a pfd in bytestream to the user in an updatepanel, but I can't get it to work.
Print print = new Print();
byte[] pdfTra开发者_如何学JAVAnsport;
pdfTransport = //get the byte array
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=Tpt" + lblTransportNr.Text + DateTime.Now.ToString().Replace(",", "") + ".pdf");
Response.BinaryWrite(pdfTransport);
string value;
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
value = enc.GetString(pdfTransport);
Response.End();
Response.Flush();
Response.Clear();
If I use this, it works without an updatepanel in the .aspx page. When I put the page in an updatepanel I get an Parsing error. Does anyone have an idea to avoid this problem or to solve it? Thx.
Actually you can't send byte streams through an AJAX request, it's just a technology limitation. And UpdatePanel uses asynchronous requests (AJAX).
don't understand what you want.... do you want to see 1. the pdf content in a webpage, or 2. the binary of the pdf in a human readable format ?
if 1. : don't use an update panel... but an iframe to the pdf url
if 2. : don't write to the response, with set the Text property of a label within the updatepanel
精彩评论