开发者

Best way to add a formatted localized string to an ASP.NET page?

I've been using <asp:Literal runat="server" meta:resourcekey="Blah" /> with resx files 开发者_如何学JAVAin the App_LocalResources directory for translatable strings, but if my key, Blah.Text is "Enter the {0} category", how would I pass the parameter to replace {0} in this context?

I know I could use <%=string.Format(... but that seems unclean and I can't access the Local Resources in that way. What should I do for this use case?


An example of markup:

<asp:Literal runat="server" ID="Blah" />

from the code behind:

Blah.Text = string.Format(
    "Enter the {0} category", 
    GetLocalResourceObject("Blah").ToString()
);

by using GetLocalResourceObject method.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜