April 14, 2009

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>




'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP 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 has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

1 Response to "Creating a Dynamic Hyperlink in ASP.NET using the Web.Config"
  1. Anonymous said...
    June 22, 2010 2:24 PM

    Thanks! This helped me.

 

Copyright © 2009-2012 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions