How to Change the URL of an ASP.NET Hyperlink Control at runtime using jQuery

I recently was solving one of the queries at the forums where the user wanted to change the URL of a Hyperlink control at runtime. This task becomes very simple using jQuery as shown here

<html xmlns="">

<head runat="server">


<script src="Scripts/jquery-1.2.6.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function() {

        $("[id$='HyperLink1']").attr("href", "");





<form id="form1" runat="server">


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

    NavigateUrl="">Favorite Site</asp:HyperLink>





This piece of code changes the url from to

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

No comments: