[英]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.