- How to change LinkButton style programmatically

Set or change LinkButton style programmatically
LinkButton is an web server control which appear as a hyperlink control but has the same functionality of a button control. linkbutton has many built in properties to change its look and feel programmatically at run time such as ForeColor, BackColor, BorderColor, BorderStyle, BorderWidth, Height, Width, Font etc.

linkbutton ForeColor property allow us to change its text color. BackColor property help to change its background color. BorderColor property get or set the border color of linkbutton control. we can control the linkbutton font style by using its Font property sub properties such as font size, font name, font italic, font bold, font underline etc. BorderStyle property allow to apply a border style of linkbutton control.

the following c# example code demonstrate us how can we set or change linkbutton style programmatically at run time in an application.
<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
        LinkButton1.ForeColor = System.Drawing.Color.Crimson;
        LinkButton1.BackColor = System.Drawing.Color.Honeydew;
        LinkButton1.BorderColor = System.Drawing.Color.DarkRed;
        LinkButton1.Font.Size = FontUnit.XLarge;
        LinkButton1.Font.Italic = true;
        LinkButton1.BorderWidth = 2;

<html xmlns="">
<head id="Head1" runat="server">
    <title>How to set, change LinkButton style programmatically</title>
    <form id="form1" runat="server">
        <h2 style="color:Navy">LinkButton Example: Style</h2>
             Text="LinkButton Style Test"
        <br /><br />
             Text="Change LinkButton Style"

Related examples