简体   繁体   English

为什么使用<%= ConfigurationManager.AppSettings(“ MySetting”)%>导致href属性不在asp:HyperLink中呈现?

[英]Why does using <%=ConfigurationManager.AppSettings(“MySetting”)%> cause href attribute not to render in asp:HyperLink?

I am trying to bind a HyperLink control's NavigateUrl property in the markup using a server tag like so: 我正在尝试使用服务器标签将HyperLink控件的NavigateUrl属性绑定到标记中,如下所示:

<asp:HyperLink ID="lnkHelp" runat="server" NavigateUrl='<%#ConfigurationManager.AppSettings("HelpUrl")%>'>Text</asp:HyperLink>

The IDE recognizes it and I even get intellisense, but the tag ends up rendering without the href attribute. IDE可以识别它,而且我什至会得到智能感知,但是该标签最终在没有href属性的情况下呈现。 I've discovered <%$ AppSettings:HelpUrl%> and I have started using this, but I don't get intellisense with it. 我发现了<%$ AppSettings:HelpUrl%>并且已经开始使用它,但是我对它没有任何理解。 That's not a deal breaker, but intellisense is just nice. 这不是一个破坏交易的事情,但是intellisense很好。 That's a question for another time, though, so I am mainly just wanting to know why using <%# %> causes the href attribute not to render. 不过,这是另一个问题,所以我主要是想知道为什么使用<%# %>会导致href属性无法呈现。

你应该这样使用

NavigateUrl='<%$ ConfigurationSettings.AppSettings["HelpUrl"] %>'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ConfigurationManager.AppSettings 正在工作<title>但不是为了</title><asp:label></asp:label> - ConfigurationManager.AppSettings is working in <title> but not for <asp:Label> 为什么在ConfigurationManager.AppSettings [key]上调用.ToString()? - Why call .ToString() on ConfigurationManager.AppSettings[key]? ConfigurationManager.AppSettings将“\ n”转换为“\\ n”为什么? - ConfigurationManager.AppSettings convert “\n” to “\\n” why? ConfigurationManager.AppSettings缓存 - ConfigurationManager.AppSettings Caching 是ConfigurationManager.AppSettings还是仅AppSettings? - ConfigurationManager.AppSettings or only AppSettings? appSettings和ConfigurationManager.AppSettings问题 - appSettings and ConfigurationManager.AppSettings issue 努力在 ASP .NET 中使用 ConfigurationManager.AppSettings[“key”] 从 web.config 文件中读取值 - Struggling to read value from web.config file using ConfigurationManager.AppSettings[“key”] in ASP .NET ConfigurationManager.AppSettings [“ AudienceSecret”]在asp.net中返回null - ConfigurationManager.AppSettings[“AudienceSecret”] returns null in asp.net ConfigurationManager.AppSettings 获取 null? - ConfigurationManager.AppSettings getting null? 如何使用 ConfigurationManager.AppSettings - How to use the ConfigurationManager.AppSettings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM