[英]Localize text using Resources on Asp.Net WebForms in javascript
I have ASP.NET WebForms application c# based.我有基于 ASP.NET WebForms 应用程序 c# 的。
I have ImageButton我有图像按钮
<asp:ImageButton ID="divSection_btnAdd" runat="server"
OnClientClick="return TConfirm(this,'<%$Resources:Resource, Confirm%>')"/>
Problem: dont show resource value but show '<%$Resources:Resource, Confirm%>'问题:不显示资源值但显示 '<%$Resources:Resource, Confirm%>'
Resources:Resource.Confirm = 'Are you sure to delete this item?' Resources:Resource.Confirm = '你确定要删除这个项目吗?'
how to show resource key value?如何显示资源键值?
please use:请用:
1-in page code behind c#: c# 后面的 1 英寸页面代码:
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hWriter = new HtmlTextWriter(sw);
base.Render(hWriter);
writer.Write(this.Localize(sb.ToString()));
}
private const string ResourceFileName = "Resource";
private string Localize(string html)
{
MatchCollection matches = new Regex(@"Localize\(([^\))]*)\)", RegexOptions.Singleline | RegexOptions.Compiled).Matches(html);
foreach (System.Text.RegularExpressions.Match match in matches)
{
html = html.Replace(match.Value, GetGlobalResourceObject(ResourceFileName, match.Groups[1].Value).ToString());
}
return html;
}
edit ImageButton:编辑图像按钮:
<asp:ImageButton
ID="divSection_btnAdd"
runat="server"
OnClientClick="return TConfirm(this,'Localize(Confirm)')"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.