Last post Jun 11, 2008 02:23 AM by msch-prv
Jun 10, 2008 03:58 AM|msch-prv|LINK
I'm trying to localize a usercontrol (footer.ascx) to no avail. Footer.ascx is included in the site's user control folder (UserCtl). This folder contains an App_LocalResources subfolder with the two associated resx entries (Footer.ascx.resx, Footer.ascx.FR.resx).
Localization of the wrapping page works fine. (Localization is carried out via a page base class that is inherited by all pages.)
I tried with implicit/explicit localization w/o success: only the FR locale is shown. How should I go about localizing usercontrols (Forcing usercontrols to inherit from the page base class yields an error)? TIA for any hints.
1. Footer.ascx mark-up:
<%@ Control Language="VB" ClassName="Footer" EnableViewState="false"%>
<a href="<%=strAdvUrl %>"><asp:Literal ID="Literal1" runat="server" meta:resourcekey="litAdv" /></a> |
<a href="<%=strWebUrl %>"><asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:litWeb.Text%>" /></a> |
Jun 10, 2008 08:31 AM|msch-prv|LINK
Well, I found a workaround for localizing the usercontrol by moving both resx files to the App_GlobalResources folder and assigning the resx values inside the usercontrol's Init event. (Requires renaming ie. litAdv.Text --> litAdv, etc.)
1. From my understanding, usercontrols cannot be localized implicitly. Is this correct or is there an alternative?
2. Must usercontrol resx resources be moved to the App_GlobalResources?
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Me.litAdv.Text = Resources.Footer.ascx.litAdv
Me.litWeb.Text = Resources.Footer.ascx.litWeb
Jun 11, 2008 02:23 AM|msch-prv|LINK