Data Cogs Information Technology

posts - 137, comments - 144, trackbacks - 42

General

Search This Site

Powered by Google

Brisbane

Locations of visitors to this page

Archives

In a lot of the web applications that I write, there is a need to stream a report back to the browser as a PDF.   With code something like this:

 //response to user's web.
            Response.Expires = 0;
            Response.Buffer = true;
            Response.ClearContent();
            Response.AddHeader("content-disposition", "inline; filename=" + "output.pdf");
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(outBuf);
            outStream.Close();
            Response.End();

Now that I am playing around with the Ajax Toolkit (specifically the ModalPopupExtender) in Visual Studio 2008, it has become clear that you really need to control whether you want asynch or full postback.

If your button that produces the report is in an UpdatePanel, and you are manipulating the Reponse to stream the report back, then you will probably want a normal postback.

This is accomplished by adding a Triggers element to your UpdatePanel as below:

 <asp:UpdatePanel ID="UpdatePanel2" runat="server">
<Triggers>
 <asp:PostBackTrigger ControlID="btnApplicationOK" />
 </Triggers>

In this case the button btnApplicationOK is inside the UpdatePanel so it's default behaviour is to perform a partial (Ajax) postback and it will not like you manipulating the Reponse, so you will get an error like the one below. The fix is to add the PostBackTrigger as mentioned.

 

posted on Wednesday, January 14, 2009 11:38 AM

Feedback

# re: Ajax PageRequestManagerParserErrorException when streaming a Reporting Services Report as PDF

Well said. Thanks for sharing!
5/24/2009 5:28 AM | siamese cat

# SSRS PDF Format &laquo; Sladescross&#039;s Blog

SSRS PDF Format &laquo; Sladescross&#039;s Blog
1/28/2010 9:33 PM | Pingback/TrackBack

Post Comment

Title  
Name  
Url
Comment   
Protected by Clearscreen.SharpHIPEnter the code you see: