Reputation: 563
I use a WebResources.resx to translate all strings in the Web UI. It works like:
<asp:Button ID="Button1" runat="server"
Text="<%$ Resources:WebResources, Button1Caption %>" />
But if I try to use the onClientClick-Attribute, the string will not be resolved. What's wrong? Or how can I do it right?
<asp:Button ID="Button1" runat="server"
Text="<%$ Resources:WebResources, Button1Caption %>" onClientClick="return confirm('<%$ Resources:WebResources, ConfirmThisClick %>');" />
Upvotes: 3
Views: 5514
Reputation: 2923
You can try adding the onclick handler in the code-behind
Button1.Attributes.Add("OnClick","DoStuff(" + WebResources.ConfirmThisClick =");
Upvotes: 0
Reputation: 22148
I'm not sure what the issue is when asp.net is rendering your strings, but one way to fix it would be to set the OnClientClick
property in the code behind:
Button1.OnClientClick = string.format("return confirm('{0}')", WebResources.ConfirmThisClick);
Upvotes: 1