Very often we need to have localized labels in our web pages (there are lots of them). The problem is that in each page or user control (ascx) in the code behind we have to add code similar to this:
LocalizationUtility.AddLabelText(lblCurrency);
LocalizationUtility.AddHoverHelp(hlCurrencyHelp);
The localized text of these controls (label and hyperlink) is fetched in the load event based on the control’s ID. It would make the developer’s life much easier if we had specialized controls for such labels and hyperlinks:
<%@ Register Assembly="dashCommerce.ServerControls" TagPrefix="dash" Namespace="MettleSystems.dashCommerce.ServerControls" %>
<dash:LocalLabel ID="lblLanguage" runat="server" CssClass="label" AssociatedControlID="ddlLanguage" />
<dash:HelpHyperLink ID="hlLanguageHelp" runat="server" NavigateUrl="javascript:void(0);">
<asp:Image ID="Image1" runat="server" SkinID="help" /></dash:HelpHyperLink>
Thus, the code behind for loading the localized text disappears and one doesn’t have to remember to write it every time a new such control is added to the page. All one has to do is add the text in the Labels.resx or to Help.resx resource files.
The source code of these little but very helpful controls is below. Hope they will be adopted by the development team at dashCommerce.
ServerControls.zip (755.71 kb)