Set or change Label font name programmatically
Label is an asp.net web server control. this control display text on asp.net web page. label control has a
built in property to set or change its font name programmatically at run time.
label Font property have many sub properties to apply its font associated settings such as font name, text size, underline or bold text etc. we can use Font property's sub property programmatically in the form Property.Subproperty. so we can change the label font name as the way Font.Name property value. font name sub property get or set the primary font name of label control such as Verdana, Comic Sans MS, Tahoma.
the following asp.net c# example code demonstrate us how can we set or change label font name dynamically at run time in an asp.net application.
label Font property have many sub properties to apply its font associated settings such as font name, text size, underline or bold text etc. we can use Font property's sub property programmatically in the form Property.Subproperty. so we can change the label font name as the way Font.Name property value. font name sub property get or set the primary font name of label control such as Verdana, Comic Sans MS, Tahoma.
the following asp.net c# example code demonstrate us how can we set or change label font name dynamically at run time in an asp.net application.
LabelFontName.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
Label1.Font.Name = "Verdana";
}
protected void Button2_Click(object sender, System.EventArgs e)
{
Label1.Font.Name = "Tahoma";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change Label font name programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">Label Example: Font Name</h2>
<asp:Label
ID="Label1"
runat="server"
Text="Click button for change font."
ForeColor="MediumOrchid"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="SteelBlue"
Text="Apply Verdana Font"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
Font-Bold="true"
ForeColor="SteelBlue"
Text="Apply Tahoma Font"
OnClick="Button2_Click"
/>
</div>
</form>
</body>
</html>
- How to set, change Label border color programmatically
- How to set, change Label border style programmatically
- How to set, change Label border width programmatically
- How to set, change TextBox font name
- How to set, change TextBox font size
- How to set, change TextBox ForeColor (font, text color)
- How to set, change TextBox height programmatically
- How to convert TextBox TextMode SingleLine to MultiLine
- How to use theme and skin id (SkinID) in TextBox
- How to set, change TextBox read only mode (ReadOnly)