asp.net - Change a HyperLink navigate URL programmatically

HyperLink navigate url
HyperLink is an asp.net web server control. hyperlink control allow us to create a link to another web page. hyperlink server control give us a great facility to work with hyperlink by server code. hyperlink control have a built in property to set or change its navigate url programmatically at run time.

hyperlink NavigateUrl property get or set the url to link to when the hyperlink control is clicked. this property value type is System.String. this 'String' represents the url to link to when the hyperlink control is clicked. the NavigateUrl property default value is an empty string that means no url is set for hyperlink navigation.

the following asp.net c# example code demonstrate us how can we set or change hyperlink navigate url programmatically at run time in an asp.net application.
HyperLinkNavigateUrl.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        HyperLink1.Text = "CheckBox Border Width Example";
        HyperLink1.NavigateUrl = "~/CheckBox/CheckBoxBorderWidth.aspx";
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        HyperLink1.Text = "CheckBox Text Color Example";
        HyperLink1.NavigateUrl = "~/CheckBox/CheckBoxForeColor.aspx";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change HyperLink navigate url (NavigateUrl) programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Red">HyperLink Example: Change NavigateUrl</h2>
        <asp:HyperLink 
             ID="HyperLink1"
             runat="server"
             Text="CheckBox Border Color Example"
             Font-Size="Large"
             Font-Bold="true"
             NavigateUrl="~/CheckBox/CheckBoxBorderColor.aspx"
             >
        </asp:HyperLink>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="Red"
             Text="Change HyperLink NavigateUrl"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="Red"
             Text="HyperLink Another NavigateUrl"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
More asp.net examples