0

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

3
  • ICBW, but don't all asp: controls need an ID? Commented Dec 2, 2013 at 21:06
  • @AndrewMorton no, they don't necessarily need an ID. Though I'm not sure why one would do that. But it will work. Commented Dec 2, 2013 at 21:34
  • Hi, the problem was that site was already compiled and i want to just add one static variable, without recompiling code,as i am no author of the code Commented Dec 7, 2013 at 21:34

1 Answer 1

1

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"]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.