- How to change a Button style programmatically

Button style
Button is an web server control. this server control render a push button on web page. button server control have many built in properties to change its default styles programmatically such as ForeColor, BackColor, BorderStyle, BorderWidth, BorderColor, Font property etc.

the following c# example code demonstrate us how can we set or change the button server control's style programmatically at run time. in this example code we changes the button's font size, text color, font weight, button height etc.

button's ForeColor property allow us to set or change button's text color. button's Font property's sub properties allow us to change button's font name and text styles such as bold, underline, italic.

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

<!DOCTYPE html>

<script runat="server">
    protected void Button2_Click(object sender, System.EventArgs e)
        Button1.Font.Size = FontUnit.Medium;
        Button1.ForeColor = System.Drawing.Color.OrangeRed;
        Button1.Font.Bold = true;
        Button1.Height = 50;
        Button1.Font.Italic = true;

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