DropDownList Border Color
dropdownlist BorderColor property get or set the border color of dropdownlist control.
asp.net developers can set or change dropdownlist border color programmatically at run time by using
this BorderColor property. they can assign BorderColor property value in c# script code section by
System.Drowing.Color. Color represents the border color of dropdownlist control. Color type
exposes many members such as AliceBlue, Red, Green, Blue, Crimson, BurlyWood, CadetBlue etc.
we can also assign dropdownlist border color using declarative syntax by set a value to BorderColor property. the following c# example code demonstrate us how can we set or change dropdownlist border color at run time.
we can also assign dropdownlist border color using declarative syntax by set a value to BorderColor property. the following c# example code demonstrate us how can we set or change dropdownlist border color at run time.
DropDownListBorderColor.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
DropDownList1.BorderWidth = 2;
}
protected void Button1_Click(object sender, System.EventArgs e)
{
DropDownList1.BorderColor = System.Drawing.Color.SeaGreen;
}
protected void Button2_Click(object sender, System.EventArgs e)
{
DropDownList1.BorderColor = System.Drawing.Color.Crimson;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change DropDownList border color programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">DropDownList: BorderColor</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Bold="true"
ForeColor="DarkGreen"
Text="asp.net controls"
>
</asp:Label>
<asp:DropDownList
ID="DropDownList1"
runat="server"
>
<asp:ListItem>ChangePassword</asp:ListItem>
<asp:ListItem>CompareValidator</asp:ListItem>
<asp:ListItem>UpdateProgress</asp:ListItem>
<asp:ListItem>LinqDataSource</asp:ListItem>
<asp:ListItem>UpdatePanel</asp:ListItem>
</asp:DropDownList>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Font-Bold="true"
ForeColor="DarkGreen"
Text="DropDownList SeaGreen Border"
OnClick="Button1_Click"
/>
<asp:Button
ID="Button2"
runat="server"
Font-Bold="true"
ForeColor="DarkGreen"
Text="DropDownList Crimson Border"
OnClick="Button2_Click"
/>
</div>
</form>
</body>
</html>