Localization ASP.NET ReportViewer Control - "ReportViewer Localization" by implementing IReportViewerMessages Interface with ReportViewerCustomMessages Class
ASP.NET ReportViewer controls enables ASP.NET developers to display Report files and reports created using Microsoft reporting technology.
Microsoft reporting technology means the MS SQL Server Reporting Services reports (.rdl files) as server reports or the .rdlc files created as local reports within the ASP.NET web site project.
SSRS (SQL Server Reporting Services) .rdl files are displayed on the ASP.NET ReportViewer control as remote reports.
ReportViewer control enables also an integrated authentication and authorization control over reports in ASP.NET applications.
Below you can see an aspx ReportViewer control in action.
One important issue with ASP.NET web sites is the localization. Although ReportViewer control has built-in support for localization of Report Viewer control itself in several languages, if you are want to localize the reportviewer control in other languages than the supported ones you might have some problems.
In this articles I'd like to give you a downloadable sample ASP.NET web site application which uses ReportViewer localization for Turkish which does not have builtin localization support for ASP.NET ReportViewer control.
ASP.NET ReportViewer can be localized by using a customized class (I named it ReportViewerCustomMessages) which implements the Microsoft.Reporting.WebForms.IReportViewerMessages interface.
When you implement the IReportViewerMessages interface you can insert your localization solution within this class.
I am using ASP.NET localization using resource files. I have attached the resource files for default culture, tr-TR Turkish culture and el-GR Greek culture at the bottom downloads section of the article.
Below I have copied two screenshots from the sample ASP.NET localization of ReportViewer component for Turkish and Greek.
Step-by-Step Building Sample ASP.NET ReportViewer Localization Web Site Project
Create an ASP.NET Web site project.
Add the ReportViewerCustomMessages class to the web site project in a class file named ReportViewerCustomMessages.vb and place it into the App_Code ASP.NET folder.
Add the customized resources files to the App_GlobalResources ASP.NET folder.
Resource.resx file for default, Resource.tr-TR.resx resource file is required for Turkish and Resource.el-GR.resx resource file is required for Greek.
Add a local Report file using the Add New Item to the web site.
Open the Default.aspx in design mode and from the Toolbox, display the contents of the Reporting tab.
Drag and drop the MicrosoftReportViewer control onto the design surface of the default.aspx page.
Configure the ReportViewer control in order to display your report (.rdlc) file.
Set the CurrentUICulture property of the CurrentThread in the default.aspx page on Page_Load event.
For Turkish (tr-TR) and for Greek (el-GR) respectively.
Dim trTR As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("tr-TR")
Threading.Thread.CurrentThread.CurrentUICulture = trTR
Dim elGR As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("el-GR")
Threading.Thread.CurrentThread.CurrentUICulture = elGR
Open the web.config file and add the following key - value pair within the <appSettings> tags.
<add key="ReportViewerMessages" value="ReportViewerCustomMessages, APP_CODE"/>
ReportViewer Web.Config Configuration Settings
The above web.config settings for the custom ReportViewerMessages can cause problems if you do not set it in the correct way.
To keep it simple, I placed the ReportViewerCustomMessages class within the App_Code folder.
So in the appSettings key, the class name is "ReportViewerCustomMessages" and the namespace is identified as "APP_CODE".
You can find more detailed information on Web.Config settings for "ReportViewerMessages" at MSDN IReportViewerMessages Interface.
There the web.config settings is for the ReportViewerMessages key is shown as :
<appSettings>
<add key="ReportViewerMessages" value="MyClass, MyAssembly" />
</appSettings>
You will find far more detail on web.config configuration settings for ReportViewer here.
ReportViewer Localization Sample Project Downloads
Download sample web site project here : Localize ASP.NET ReportViewer Sample with Code
ReportViewerCustomMessages class file : ReportViewerCustomMessages.vb
Default resource file : Resource.resx
tr-TR Turkish resource file : Resource.tr-TR.resx
el-GR Greek resource file : Resource.el-GR.resx
