Reputation: 458
I have compiled ASP.NET dynamic page with editable aspx pages. I would like to some links to be generated upon changing some static variable What i did is edit:
web.config as follows:
<appSettings>
<add key="currentEnvironment" value="dev-"/>
</appSettings>
and then edited aspx page as follows
<a href="http://<asp:Literal runat ="server" Text='<%# ConfigurationSettings.AppSettings["currentEnvironment"] %>'></asp:Literal>www.mysite.com/web/index.html">Home</a>
But there is nothing appened when i try and run the .aspx page. Please help
Upvotes: 0
Views: 85
Reputation: 15797
You can't put a server tag inside another tag's markup like that, but you can just use the value directly. If you remove it and change the #
to a =
, it will work.
<a href="http://<%= ConfigurationSettings.AppSettings["currentEnvironment"] %>www.mysite.com/web/index.html">Home</a>
Although if you can access the code behind, that would be a much cleaner way to do it, as in:
<asp:HyperLink ID="_index" runat="server">Home</asp:HyperLink>
and then set value from code behind
_index.NavigateUrl = String.Format("http://{0}www.mysite.com/web/index.html", ConfigurationSettings.AppSettings["currentEnvironment"]);
Upvotes: 1