2012-02-02 135 views
3

我寫了一個ASP.Net程序,使用資源鍵支持多語言支持我可以在HTML中使用resourcekey嗎?

現在我想標記化這個模塊,使用戶可以給它模板。

因爲我給令牌給用戶把它放在模塊中,我會替換它。例如,如果用戶鍵入[lblsomething在HTML我將與

<span id="lblsomething"> something </span> 

替換現在的問題是如何使用資源鍵與此跨度,支持多語言,就像我在ASP.Net <asp:label resourcekey="lblsomething"></asp:label>

非常感謝任何幫助,您可以提供

回答

2

,你可以嘗試在CS:

string something=Localization.GetString("KEY" , this.LocalResourceFile); 
string html="<span id="lblsomething">"+something+"</span>" 

,然後HTML字符串由atabrizi好好嘗試一下工作,爲我添加到

+0

嘿atabrizi,您的解決方案是偉大的,謝謝您的回答 – Mosijava 2012-02-05 08:30:38

3

您neeed添加RUNAT =「服務器」的控制。

<span id="something" runat="server" meta:resourcekey="PressMeButtonResources"/> 

或者,你可以使用span標記內字面控制

3

奇怪的解決方案Localization.GetString ...。

這工作在我的情況(在表格的例子生日標籤+文本框):

<label for="birthday"> 
    <%=GetLocalResourceObject("form_Birthday.Text").ToString()%> 
</label> 
<input type="text" id="birthday" name="birthday" /> 

msdn: How to: Retrieve Resource Values Programmatically

相關問題