[英]How to set resource key to anchor HREF tag on aspx page in asp.net localization
I want to set Resource key
to the below href
of anchor tag
and used below two approaches. 我想将
Resource key
设置为anchor tag
的以下href
,并在以下两种方法中使用。
<a href='<%$ Resources:Resource, NewsletterArchive %>' class="button action blue"> </a>
AND 和
<a href='<%=CommunityServer.Web.ResourceLibrary.Resource.NewsletterArchive %>' class="button action blue"> </a>
But, no luck.. Got the below error 但是,没有运气..得到了以下错误
> Literal expressions like '<%$ Resources:Resource, NewsletterArchive > %>' are not allowed. Use <asp:Literal runat="server" Text="<%$ > Resources:Resource, NewsletterArchive%>" /> instead.
Please, help. 请帮忙。
Your first approach should work correctly. 您的第一种方法应该可以正常工作。 But if it is not working, you may use code behind.
但是,如果它不起作用,则可以在后面使用代码。
Your design page: 您的设计页面:
<a id="hprLink" runat="server" class="button action blue">It is my link</a>
Your code behind: 您的代码背后:
hprLink.Attributes.Add("href", GetGlobalResourceObject("your_resource_file", "your_resource_key").ToString());
Not sure if this helps, but this worked for me: 不知道这是否有帮助,但这对我有用:
<a href="<asp:Literal runat="server" Text="<%$Resources:Branding, footerAboutLink%>" />">
<asp:Label ID="footerAbout" runat="server" Text="<%$Resources:Branding, footerAbout%>"></asp:Label></a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.