结合ASP.Net web.config设置为.aspx文件&LT; A HREF&GT;&LT; / A&GT ;? [英] 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>
帮助很大AP preciated。
Help greatly appreciated.
对不起,我应该提到,这是一个HTML链接: **&LT; A HREF&GT;&LT; / A&GT; **
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 %>'
和充分&下;一>标签的定义是:
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文件&LT; A HREF&GT;&LT; / A&GT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!