If you need to replace any label text in the report viewer, such as NULL, you can create the following class which implements IReportViewerMessages. This was very difficult to find figure out from my google researching. I had to piece information together from here and there to get it working for me so I am posting this today to be an 'all in one'!
I had trouble creating the class within the web application, so I had to add it to a separate project, which one already existed and was being referenced by the web project any way. I copied the dll produced by that project into the bin folder of the web project, and then added the following appSetting to the web.config file of the web project:
<add key="ReportViewerMessages" value="MyNameSpace.MyCustomReportViewerMessages, AssemblyNameOfYourProjectThatContainsThisFile"/ >
I'll be honest, big words like Assembly reference scare me. That could be any thing and is so generic sounding and it could be written so many ways, in this case NameSpace.ClassName, TheAssemblyFileName which I think boils down to the name of the dll file with out the 'dll' part.
When you run the report, you may get an invalid file exception, review what you have referenced in the web.config. I had a typo I kept overlooking.
And unfortunately, you have to 'implement' all so that means this entire file will replace every label. Double-check my work for me would ya...or risk some crazy label I missed :)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Reporting.WebForms;
namespace MyNameSpace
{
public class MyCustomReportViewerMessages : IReportViewerMessages
{
//overwrite the default labels in the report viewer
public string NullCheckBoxText { get { return "All"; } }
public string NullCheckBoxToolTip { get { return "All"; } }
public string NullValueText { get { return "All"; } }
public string DocumentMapButtonToolTip { get { return "Document Map"; } }
public string ParameterAreaButtonToolTip { get { return "Show/Hide Parameters"; } }
public string FirstPageButtonToolTip { get { return "First Page"; } }
public string PreviousPageButtonToolTip { get { return "Previous Page"; } }
public string CurrentPageTextBoxToolTip { get { return "Current Page"; } }
public string PageOf { get { return "of"; } }
public string NextPageButtonToolTip { get { return "Next Page"; } }
public string LastPageButtonToolTip { get { return "Last Page"; } }
public string BackButtonToolTip { get { return "Back"; } }
public string RefreshButtonToolTip { get { return "Refresh"; } }
public string PrintButtonToolTip { get { return "Print"; } }
public string ExportButtonToolTip { get { return "Export"; } }
public string ZoomControlToolTip { get { return "Zoom Control"; } }
public string SearchTextBoxToolTip { get { return "Search Text"; } }
public string FindButtonToolTip { get { return "Find Buttonp"; } }
public string FindNextButtonToolTip { get { return "Find Next"; } }
public string ZoomToPageWidth { get { return "Zoom To Page Width"; } }
public string ZoomToWholePage { get { return "Zoom To Whole Page"; } }
public string FindButtonText { get { return "Find"; } }
public string FindNextButtonText { get { return "Find Next"; } }
public string ViewReportButtonText { get { return "View Report"; } }
public string ProgressText { get { return "Progress Text"; } }
public string TextNotFound { get { return "Text Not Found"; } }
public string NoMoreMatches { get { return "No More Matches"; } }
public string ChangeCredentialsText { get { return "Change Credentials Text"; } }
public string TrueValueText { get { return "True"; } }
public string FalseValueText { get { return "False"; } }
public string SelectAValue { get { return "Select A Value"; } }
public string UserNamePrompt { get { return "User Name"; } }
public string PasswordPrompt { get { return "Password Prompt"; } }
public string SelectAll { get { return "Select All"; } }
public string PrintLayoutButtonToolTip { get { return "Print Layout"; } }
public string PageSetupButtonToolTip { get { return "Page Setup"; } }
public string TotalPagesToolTip { get { return "Total Pages"; } }
public string StopButtonToolTip { get { return "Stop"; } }
public string DocumentMapMenuItemText { get { return "Document Map"; } }
public string BackMenuItemText { get { return "Back"; } }
public string RefreshMenuItemText { get { return "Refresh"; } }
public string PrintMenuItemText { get { return "Print"; } }
public string PrintLayoutMenuItemText { get { return "Print Layout"; } }
public string PageSetupMenuItemText { get { return "Page Setup"; } }
public string ExportMenuItemText { get { return "Export"; } }
public string StopMenuItemText { get { return "Stop"; } }
public string ZoomMenuItemText { get { return "Zoom"; } }
public string ViewReportButtonToolTip { get { return "View Report"; } }
public string TodayIs { get { return "Today Is"; } }
public string ChangeCredentialsToolTip { get { return "Change Credentials"; } }
public string DocumentMap { get { return "Document Map"; } }
public string ExportButtonText { get { return "Export"; } }
public string ExportFormatsToolTip { get { return "Export Formats"; } }
public string InvalidPageNumber { get { return "?"; } }
public string SelectFormat { get { return "Select Format"; } }
}
}
No comments:
Post a Comment