asp.net - How to change a HyperLink text color programmatically

Change HyperLink text color programmatically
The HyperLink is a control that displays a link to another Web page. The asp.net developers use the HyperLink control to create a link to another Web page. The HyperLink web server control is typically displayed as text specified by the Text property. But the asp.net c# developers can also display an image on it specified by the ImageUrl property.

The following asp.net c# tutorial code demonstrates how we can change the HyperLink text color programmatically. Here we change the HyperLink text color programmatically using its ForeColor property.

The HyperLink ForeColor property gets or sets the foreground color (typically the color of the text) of the Web server control. The HyperLink ForeColor property is inherited from WebControl.

The ForeColor property value is a Color that represents the foreground color of the control. The default value of this property is Empty. A Color represents an ARGB (alpha, red, green, blue) color. So finally, using the HyperLink control’s ForeColor property the asp.net c# developers can change the HyperLink’s text color programmatically.
HyperLinkForeColor.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        HyperLink1.ForeColor = System.Drawing.Color.SeaGreen;
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        HyperLink1.ForeColor = System.Drawing.Color.Crimson;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change HyperLink ForeColor (text, link color)</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy">HyperLink Example: ForeColor</h2>
        <asp:HyperLink 
             ID="HyperLink1"
             runat="server"
             Text="Go To ListBox Skin Page"
             Font-Size="Larger"
             Font-Italic="true"
             Font-Bold="true"
             NavigateUrl="~/ListBox/ListBoxSkin.aspx"
             >
        </asp:HyperLink>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="SaddleBrown"
             Text="HyperLink ForeColor SeaGreen"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="SaddleBrown"
             Text="HyperLink ForeColor Crimson"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
More asp.net examples