asp.net - How to change a DropDownList border style programmatically

DropDownList Border Style
dropdownlist web server control allow users to select a single item from its items collection. dropdownlist BorderStyle property get or set the border style of dropdownlist control. this property overrides the WebControl.BorderStyle default value. we can specify dropdownlist control's border style by applying any value from BorderStyle enumeration. BorderStyle enumeration have many values such as Dashed, Dotted, Double, Groove, Inset, OutSet etc.

so we can apply different border style of dropdownlist control by using BorderStyle enumeration. the following c# example source code demonstrate us how can we set or change dropdownlist border style programmatically at run time in asp.net.
DropDownListBorderStyle.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e)
    {
        DropDownList1.BorderColor = System.Drawing.Color.DodgerBlue;
        DropDownList1.BorderWidth = 2;
    }
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        DropDownList1.BorderStyle = BorderStyle.Dotted;
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        DropDownList1.BorderStyle = BorderStyle.Dashed;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change DropDownList border style programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy">DropDownList: BorderStyle</h2>
        <asp:Label 
             ID="Label1"
             runat="server"
             Font-Bold="true"
             ForeColor="Firebrick"
             Text="asp.net controls"
             >
        </asp:Label>
        <asp:DropDownList 
             ID="DropDownList1"
             runat="server"
             >
             <asp:ListItem>ImageMap</asp:ListItem>
             <asp:ListItem>EntityDataSource</asp:ListItem>
             <asp:ListItem>CompareValidator</asp:ListItem>
             <asp:ListItem>TreeView</asp:ListItem>
             <asp:ListItem>Literal</asp:ListItem>
        </asp:DropDownList>
        <br /><br />
        <asp:Button 
             ID="Button1"
             runat="server"
             Font-Bold="true"
             ForeColor="Firebrick"
             Text="DropDownList Dotted Border"
             OnClick="Button1_Click"
             />
        <asp:Button 
             ID="Button2"
             runat="server"
             Font-Bold="true"
             ForeColor="Firebrick"
             Text="DropDownList Dashed Border"
             OnClick="Button2_Click"
             />
    </div>
    </form>
</body>
</html>
More asp.net examples