Nested content localization in ASP.NET
Having the following markup
<p>
No items found. Want to
<asp:LinkButton ID="LinkButton1" runat="server" OnCommand="LinkButton1_Command" Text="create" />
a new one?
</p>
开发者_JAVA技巧
how do i localize both the text and LinkButton.Text? I don't want to create two literals that frame the link. Is there a better way?
If you could get away with a straight HTML solution instead of the asp:LinkButton, you could embed the entire thing into one resource string.
No items found. Want to a <href="javascript:__doPostBack('Link1','')">create</a> a new one?
You'd then have to manually check the Request["__EVENTTARGET"] instead of using the wired up event handler.
I'm not saying it's a good idea, but I guess it could work.
In this particular case you pretty much have to. However, your grammar is more complex than it needs to be - you would probably never insert a different word before "a new one" - e.g. "Want to [delete] a new one?" doesn't make sense. So I'd recommend putting "a new one" as part of the link text, so you only need one literal for the "No items found".
精彩评论