LinkButton text color
LinkButton is an asp.net web server control. linkbutton web server control display a hyperlink-style
button control in web page. linkbutton server control have a built in property to assign or change its text color
programmatically at run time.
linkbutton ForeColor property allow us to get or set the foreground color of linkbutton control. linkbutton foreground color is the text color of linkbutton. by using this property we can set or change linkbutton font, text color dynamically at run time. linkbutton ForeColor property value type is System.Drawing.Color. the 'Color' represents the text color of linkbutton control. this property default value is Empty which indicate no color is set for this property value. we need to import System.Drawing namespace to assign linkbutton text color programmatically.
the following asp.net c# example code demonstrate us how can we change linkbutton text color programmatically at run time in an asp.net application. in this example we assign HotPink or DodgerBlue color as linkbutton text color by two button click event.
linkbutton ForeColor property allow us to get or set the foreground color of linkbutton control. linkbutton foreground color is the text color of linkbutton. by using this property we can set or change linkbutton font, text color dynamically at run time. linkbutton ForeColor property value type is System.Drawing.Color. the 'Color' represents the text color of linkbutton control. this property default value is Empty which indicate no color is set for this property value. we need to import System.Drawing namespace to assign linkbutton text color programmatically.
the following asp.net c# example code demonstrate us how can we change linkbutton text color programmatically at run time in an asp.net application. in this example we assign HotPink or DodgerBlue color as linkbutton text color by two button click event.
LinkButtonForeColor.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
LinkButton1.ForeColor = System.Drawing.Color.HotPink;
}
protected void Button2_Click(object sender, System.EventArgs e)
{
LinkButton1.ForeColor = System.Drawing.Color.DodgerBlue;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change LinkButton ForeColor (text, font color)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">LinkButton Example: ForeColor</h2>
<asp:LinkButton
ID="LinkButton1"
runat="server"
Text="LinkButton ForeColor Test"
Height="25"
BackColor="LightGoldenrodYellow"
Font-Size="Large"
>
</asp:LinkButton>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="SaddleBrown"
Text="LinkButton Text HotPink"
Height="45"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
ForeColor="SaddleBrown"
Text="LinkButton Text DodgerBlue"
Height="45"
OnClick="Button2_Click"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>


