Create and apply CSS style programmatically in asp.net

How to create and apply CSS style programmatically in asp.net control
CreateAndApplyCSSStyle.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        BulletedList1.Style.Add("Padding", "10px 25px 10px 55px");
        BulletedList1.Style.Add("font-family", "Courier New");
        BulletedList1.Style.Add("font-size", "x-large");
        BulletedList1.Style.Add("font-style", "italic");
        BulletedList1.Style.Add("text-decoration", "underline");
        BulletedList1.Style.Add("border", "2px dotted darkred");
        BulletedList1.Style.Add("background-color", "pink");
        BulletedList1.Style.Add("color", "deeppink");
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to create and apply CSS style programmatically in asp.net control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:MidnightBlue; font-style:italic;">
            How to create and apply CSS style
            <br /> programmatically in asp.net control
        </h2>
        <hr width="450" align="left" color="SkyBlue"/>
        <asp:BulletedList
             ID="BulletedList1"
             runat="server"
             Width="500"
             BackColor="Crimson"
             ForeColor="Snow"
             >
             <asp:ListItem>Crimson</asp:ListItem>
             <asp:ListItem>MidnightBlue</asp:ListItem>
             <asp:ListItem>CornFlower</asp:ListItem>
             <asp:ListItem>DarkSalmon</asp:ListItem>
             <asp:ListItem>IndianRed</asp:ListItem>
             <asp:ListItem>OliveDrab</asp:ListItem>
        </asp:BulletedList>
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Create And Apply CSS Style In BulletedList"
            Height="45"
            Font-Bold="true"
            ForeColor="DarkBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples