asp.net - How to change Label font size programmatically

Label font size
Label is an asp.net web server control which display text on web pages. label control's Font property have many sub properties those let us change the font associated settings programmatically.

The Font property value type is System.Web.UI.WebControls.Fontinfo. this 'FontInfo' represents the font properties of label server control. we can apply bold, italic or underlined text using Font property. we also can set the font (text) size and font name using Font property's sub properties.

We can assign the font size programmatically in the form of Property.Subproperty such as Font.Size. we can set any one of the value from FontUnit enumeration as font size sub property value such as Large, Medium, Small.

The following asp.net c# example code demonstrate us how can we set or change label control's font size programmatically in an asp.net application.
LabelFontSize.aspx

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

<!DOCTYPE html>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change Label font size programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Red">Label Example: Font Size</h2>
        <asp:Label 
             ID="Label1" 
             runat="server"
             Text="Click button for change font size."
             BorderColor="Green"
             BorderWidth="2"
             ForeColor="DodgerBlue"
             >
        </asp:Label>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server" 
             ForeColor="IndianRed"
             Text="Label Large Font"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server" 
             Font-Bold="true"
             ForeColor="IndianRed"
             Text="Label XLarge Font"
             OnClick="Button2_Click"
             />
    </div>
    </form>
</body>
</html>
More asp.net examples