can I use resourcekey in HTML?

会有一股神秘感。 提交于 2019-12-10 21:55:34

问题


I wrote an ASP.Net Program that use resource key to support multi language support

Now I want to tokenize this module to enable user give template to it.

for that I give tokens to user to drop it in module and I will replace it. for example if user type [lblsomething] in HTML I will replace it with

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

Now the problem is how can i use resource key with this span to support multi language just like what i have in ASP.Net <asp:label resourcekey="lblsomething"></asp:label>

Thanks a lot for any help you can provide


回答1:


you can try it in cs:

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

and then add html string to page




回答2:


You neeed to add runat="server" to the control.

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

Or alternatively, you can use literal control inside the span tag.




回答3:


Strangely the solution Localization.GetString... by atabrizi doens't work for me.

This works in my case (example for birthday label + textbox in a form):

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

msdn: How to: Retrieve Resource Values Programmatically



来源:https://stackoverflow.com/questions/9109315/can-i-use-resourcekey-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!