AppSettings shourtcut question
-
20-09-2019 - |
Question
I am trying to use the <%$ AppSettings: .. %> shortcut in an asp.net user control.
I am able to use the syntax fine when binding a property to an appsetting, however I want to use an appsetting to hold a page id. for exmaple:
<a href="default.aspx?page=<%$ AppSettings:TestPageID %>">Test link</a>
This method does not work, so my question is, can the appsetting shortcut be used like this to insert a literal, or can anybody suggest a way I can achieve this.
Many thanks,
Adam
Solution
add literal into the anchor tag.
<a href="/default.aspx?page=<asp:Literal runat="server" Text="<%$ appSettings:TestPageId %>"/>">Test Link</a>
OTHER TIPS
Try:
<%= System.Configuration.ConfigurationSettings.AppSettings.Get("TestPageID") %>
Just add runat=server to the original 'a' tag and everything will work properly like this:
<a runat="server" href="default.aspx?page=<%$ AppSettings:TestPageID %>">Test link</a>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow