开发者

How to provide translations for items in a ASP.Net custom web control (.ascx)?

How do I go about providing localised text for items in a custom web control? I had thought that I just need to add meta.resourcekey tags to the control items and then define and fill some resource files called mycontrol.ascx.[lang].resx but that doesn't seem to work.

e.g.

MyControl.ascx

<asp:Label ID="Label1" meta:开发者_如何学运维resourcekey="Label1" runat="server" Text="Oops!"></asp:Label>

MyControl.ascx.de.resx

Label1.Text    Donner und Blitzen!


You dont need to add meta tags.

Have this in your resource file (MyControl.ascx.de.resx) which will be located in App_LocalResources:

Name Value


SomeName Oops!

Then in your User Control:

<asp:Label ID="Label1" meta:resourcekey="Label1" runat="server">
    <%=GetLocalResourceObject("SomeName") %>
</asp:Label>

That helper method is part of the System.Web.UI.TemplateControl namespace.


you could use global resource files for this, here is a link that may help

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜