AppSettings setting issue

I am trying to use the <% $ AppSettings: ..%> shortcut in an asp.net custom control.

I can use syntax tone when binding a property to appsetting, however I want to use appsetting to store the page id. for exmaple:

<a href="default.aspx?page=<%$ AppSettings:TestPageID %>">Test link</a>

      

This method does not work, so my question is if the appsetting shortcut can be used in such a way to insert the literal, or can anyone suggest a way that I can achieve this.

Many thanks,

Adam

+2


source to share


3 answers


add literal to anchor tag.



<a href="/default.aspx?page=<asp:Literal runat="server" Text="<%$ appSettings:TestPageId %>"/>">Test Link</a>

      

+3


source


Try:



<%= System.Configuration.ConfigurationSettings.AppSettings.Get("TestPageID") %>

      

0


source


Just add runat = server to the original 'a' tag and everything will work correctly:

<a runat="server" href="default.aspx?page=<%$ AppSettings:TestPageID %>">Test link</a>

      

0


source







All Articles