Hi,
Many of you have had frustrated experience lately with current ReportViewer control in Visual WebGui version 6.2.x, especially 6.2.3. There is a referencing problem within that version that forces users to use version 8 of the Microsoft.ReportViewer.WebForm control and that in turn does not seem to provide you with the print button. Please note that an issue has been filed about this problem (here), which will in time provide you with a permanent fix.
To try to help you some in the meantime, I decided to go through the back door (as all of you could have done of course), and simply use the new ASP.NET Wrapper to create a wrapper around the Microsoft.ReportViewer.WebForm version 9 control and see if I could use that. The results were a pleasant surprize, as with minor adjustments to the code generated by the wrapper, I could use my new ReportViewer9 control to view local reports (don't have reportserver running here, so I couldn't test remote reports).
What came as even more surprize was that with just a small trick, the FireFox display issue for the current VWG 6.2.3 ReportViewer control could be solved, so now I have a working ReportViwer control for both IE and FF3. The only difference/problem is that in FF3, then print button will not show. Didn't solve that and don't know yet if that can be solved.
I will provide you with a small temporary test application below, which includes both my wrapped control, as well as a small test program. More about that later. First, I am going to tell you what you need to do to wrap such a control your self, as it is remarkably easy ! You should first read the wrapper howto article here. My projects are written for VB.NET 2008, so my description applies to VB.NET. Minor differences can exist for C#. Everything is based on the current VWG 6.2.3 NET3.5 VS2008 SDK library.
Steps to create the wrapped control:
- Create a new project, ReportViewer9Wrapper, of type Visual WebGui Library
- Delete the UserControl1 control. You will not need it.
- Add references to Microsoft.ReportViewer.WebForms and make sure it's version 9
- Add references to System.Web
- Right click on project, select Add and then ASP.NET Control Wrapper
- In the list of control, select ReportViewer and make sure it's from the correct namespace (Microsoft.ReportViewer.WebForms) and it's version
- Name the control (at the bottom) ReportViewer9
Now you have a wrapped control that you must do minor fixes for by editing the ReportViewer9.designer.vb file (right click, view code)
- The class is now declared as "Partial Class", which means it's "Friend" and can't be used outside of the project. Change to "Partial Public Class"
- There is a declaration for "Public Sub Reset()" in the code. You will get some errors with calls to that proc. Simply rename it and have "Public Sub ResetHostedViewer()"
- You will get error for "Public Sub Dispose()", which you fix by simply set "Public OverLoads Sub Dispose()"
That is about it! Now you have a working library project with a working ReportViewer9 control that you can use in you test application.
Two things that are worth mentioning.
- FireFox 3 has problems displaying the current VWG ReportViewer control, as you can see in the Catalog demo app. The fix for that is the same as the fix Eyal Albert mentions in the Wrapper howto article (see above). Simply add the following code in your ReportViewer9 control class, and FF3 will behave:
Protected Overrides ReadOnly Property IsFixedSize() As Boolean
Get
Return True
End Get
End Property
- Second, switching report files (.rdl) at runtime, that is loading one and then loading another, requires that you call your new ResetHostedViewer() function you created above, before you load the second report. Probably best to call it before loading any report to make sure the control has been properly initialized.
Now to how to use the new wrapper in an application.
- First you have to reference your app to your new library that contains the wrapper control.
- Next you have to register your control in VWG, via the VWG integration tabs, register control.
- Then you have to add the following line to the httpHandlers section of your web.config:
<add verb="*"
path="Reserved.ReportViewerWebControl.axd"
type = "Microsoft.Reporting.WebForms.HttpHandler,
Microsoft.ReportViewer.WebForms,
Version=9.0.0.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
- Pleae note that the above should be all in one line, with no linebreaks.
The application / wrapper demo has been uploaded and you can find it here. It includes both the Wrapped control in a library, as well as two simple samples on how to use the control. One of the samples (Employees) is based on the NorthWind database, so you will get errors if you have not got that. You can view the source code anyway, and you will not get the error until you press the "Employee" button. The code is very little or not documented, except for this description here in this message. It's only purpose is to temporary help you being able to use the viewer, until the official ReportViewer will be fixed.
Hope this helps some both to see how easy it really is using the Wrapper, as well as making the ReportViewer9 control temporary available to you, until the referencing problems will be fixed in later version.
Palli