views:

105

answers:

2

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 %>');" />
+1  A: 

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);
Steve Danner
A: 

You can try adding the onclick handler in the code-behind

Button1.Attributes.Add("OnClick","DoStuff(" + WebResources.ConfirmThisClick =");
scottschulthess
Sorry, I can set only 1 answer as accepted.
Lord Vader
actually idk :)
scottschulthess