asp.net - How to change Button font size programmatically

Change Button font size programmatically
Button is an asp.net web server control that lets users to submit a page to web server. button server control's have a built in property to set or change its font size programmatically at run time. button control's Font property allow us to specify the font properties of the button control.

this Font property includes many sub properties that can be accessed programmatically in the form of Property.Subproperty such as Font.Italic. Font property's Size sub property allow us to set or change button control's font (text) size programmatically at run time. we can assign Font.Size sub property value by using FontUnit enumeration. FontUnit enumeration have many possible values such as Small, Large, Medium, Larger, Smaller, XXLarge etc.

the following asp.net c# example code demonstrate us how can we change the button control's font size dynamically at run time in an asp.net application.
ButtonFontSize.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button2_Click(object sender, System.EventArgs e)
    {
         Button1.Font.Size = FontUnit.Medium;
    }
    protected void Button3_Click(object sender, System.EventArgs e)
    {
        Button1.Font.Size = FontUnit.Large;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change Button font size programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Red">Button Example: Font Size</h2>
        <asp:Button 
             ID="Button1" 
             runat="server" 
             Text="Test Button Font Size"
             ForeColor="DarkCyan"
             Height="43"
             />
        <br /><br />
        <asp:Button 
             ID="Button2" 
             runat="server" 
             Text="Button Font Size Medium"
             OnClick="Button2_Click"
             />
        <asp:Button 
             ID="Button3" 
             runat="server" 
             Text="Button Font Size Large"
             OnClick="Button3_Click"
             />
    </div>
    </form>
</body>
</html>
Related asp.net example