asp.net example - label css style
Sometimes we need to more customize design on asp.net label control. the built in property
of label control is not sufficient for apply all of customization. here we use a simple label control
and a button control. when someone click the button then the label change it's appearance.
label apply new font family, font color, text size, background color and italic style.
label-css-style.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
Label1.CssClass = "labelstyle";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<style type="text/css">
.labelstyle {
color:red;
font-size:xx-large;
font-family:'Comic Sans MS';
background-color:snow;
font-style:italic;
}
</style>
<title>asp.net example - label css style</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
asp.net example - label css style
</h2>
<hr width="550" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Text="sample label to test label css style."
>
</asp:Label>
<br /><br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="label css style"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>


- How to add an onClick event to a Label
- How to create a multiline Label
- How to align Label text to right
- How to change Label text from JavaScript
- How to add a background image to a Label
- How to justify the text in a Label
- How to display a link in a Label
- How to add margin to a Label
- How to add top margin to a Label
- How add padding to a Label