[英]How to get text into a TextBox from a DropDownList in FormView using JavaScript in ASP.NET WebForms?
[英]Localize text using Resources on Asp.Net WebForms in javascript
我有基於 ASP.NET WebForms 應用程序 c# 的。
我有圖像按鈕
<asp:ImageButton ID="divSection_btnAdd" runat="server"
OnClientClick="return TConfirm(this,'<%$Resources:Resource, Confirm%>')"/>
問題:不顯示資源值但顯示 '<%$Resources:Resource, Confirm%>'
Resources:Resource.Confirm = '你確定要刪除這個項目嗎?'
如何顯示資源鍵值?
請用:
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;
}
編輯圖像按鈕:
<asp:ImageButton
ID="divSection_btnAdd"
runat="server"
OnClientClick="return TConfirm(this,'Localize(Confirm)')"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.