Monday, March 26, 2012

Print button in ReportViewer not working inside UpdatePanel

The print button in the toolbar of the VS reportviewer does not work when the reportviewer is contained inside an updatepanel. Does anyone know of a workaround or fix?

My report parameters are dynamically specified via dropdowns and calendars, so they must be inside an updatepanel...

Hi

I had a similar problem. To overcome I disabled the print button in the reportviewer.

I then added a button, that needs to exist outside of the updatepanel, that on clicking the button triggers code to print to pdf

Works OK and the output capability, in my case, is limited to pdf

Hope that is of help

Michael


Thanks Michael. That seems like a possible solution for me... When you click the button, does it open up Acrobat or just bring up the print menu? Also, may I see the code for the button? Thanks!


Hi

I found the solution to this problem via the attached post. It opens up acrobat.

https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=139828&SiteID=1

Also eliminates a new explorer window opening.

My code is:

ProtectedSub Button2_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)

Try

Dim warningsAs Warning() =Nothing

Dim streamidsAsString() =Nothing

Dim mimeTypeAsString =Nothing

Dim encodingAsString =Nothing

Dim extensionAsString =Nothing

Dim bytesAsByte()

bytes = ReportViewer1.LocalReport.Render("PDF",Nothing, mimeType, encoding, extension, streamids, warnings)

Response.ContentType ="Application/pdf"

Response.Clear()

Response.ContentType = mimeType

Response.AddHeader("content-disposition","attachment; filename=Report." & extension)

Response.BinaryWrite(bytes)

Response.End()

Catch exAs Exception

EndTry

EndSub

This works for me. You will get an error though if the button is inside an update panel

Cheers

Michael

No comments:

Post a Comment