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>







About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 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.