C# 如何使用ASPX文件中的资源?
我使用WebResources.resx转换Web UI中的所有字符串。它的工作原理如下:C# 如何使用ASPX文件中的资源?,c#,resources,asp.net,C#,Resources,Asp.net,我使用WebResources.resx转换Web UI中的所有字符串。它的工作原理如下: <asp:Button ID="Button1" runat="server" Text="<%$ Resources:WebResources, Button1Caption %>" /> 但是如果我尝试使用onClientClick属性,字符串将不会被解析。发生了什么?或者我怎样才能把它做好 <asp:Button ID="Button1" runat="serv
<asp:Button ID="Button1" runat="server"
Text="<%$ Resources:WebResources, Button1Caption %>" />
但是如果我尝试使用onClientClick属性,字符串将不会被解析。发生了什么?或者我怎样才能把它做好
<asp:Button ID="Button1" runat="server"
Text="<%$ Resources:WebResources, Button1Caption %>" onClientClick="return confirm('<%$ Resources:WebResources, ConfirmThisClick %>');" />
我不确定asp.net呈现字符串时会出现什么问题,但解决问题的一种方法是在代码隐藏中设置
OnClientClick
属性:
Button1.OnClientClick = string.format("return confirm('{0}')", WebResources.ConfirmThisClick);
您可以尝试在代码隐藏中添加onclick处理程序
Button1.Attributes.Add("OnClick","DoStuff(" + WebResources.ConfirmThisClick =");
如果查看生成页面的源代码,html中显示的资源应该在哪里?在html中显示的源代码中:您是指String.Format吗?