将 ASP.Net Web.Config 设置绑定到 .ASPX 文件 <a href></a>? [英] Binding ASP.Net Web.Config Settings To .ASPX File <a href></a>?
问题描述
我有一个 ASP.NET Web 项目.我希望能够在我的 web.config 文件中定义站点的所有链接,以便在需要时可以轻松更改它们.目前我有一个"我的 web.config 文件中的部分.
I have an ASP.NET web project. I want to be able to define all of the links for the site inside my web.config file so that they can be changed easily if needs be. Currently I have an "" section in my web.config file.
如何将此键值对绑定到我的 .aspx 文件中的 '' 标记?!
How do I bind this key value pair to an '' tag in my .aspx file?!
<appSettings>
<add key="MyNewLink" value="http://someurl.co.uk/" />
</appSettings>
非常感谢帮助.
对不起,我应该提到这是一个 html 链接:**</a>**
Sorry I should have mentioned that this is for a html link: **<a href></a>**
推荐答案
在你的 aspx 文件中:
In your aspx file it would be:
NavigateUrl='<%$ AppSettings:MyNewLink %>'
并且完整的 <a> 标签定义为:
and the full <a> tag is defined as:
<a runat="server" href="<%$ AppSettings:MyNewLink %>">Text link</a>
此语法只能用于 ASP.NET WebForms 服务器控件.
This syntax can only be used on an ASP.NET WebForms server control.
这篇关于将 ASP.Net Web.Config 设置绑定到 .ASPX 文件 <a href></a>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!