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

572 Views Asked by At

I am trying to bind a HyperLink control's NavigateUrl property in the markup using a server tag like so:

<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. I've discovered <%$ AppSettings:HelpUrl%> and I have started using this, but I don't get intellisense with it. That's not a deal breaker, but intellisense is just nice. 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.

1

There are 1 best solutions below

1
On

You should use like this

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