Creating a Dynamic Hyperlink in ASP.NET using the Web.Config

A user recently asked me that she wanted to create a bunch of hyperlinks whose value comes from a web.config. However she was not able to create the Hyperlink successfully by reading the key pair values. Here's how to do so:


  <appSettings>


    <add key="someurl" value="http://www.dotnetcurry.com" />


  </appSettings>




Now read this entry from the web.config using AppSettings


    <asp:HyperLink ID="HyperLink1" runat="server"


    NavigateUrl="<%$ Appsettings:someurl %>"  Text="Click Here">


    </asp:HyperLink>




Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

1 comment:

Anonymous said...

Thanks! This helped me.