System.Web.UI.WebControls Namespace
Specifies the border style of a control.
Member |
Description |
NotSet |
The border style is not set. |
None |
No border is drawn, regardless of any given BorderWidth. |
Dotted |
Border is a dotted line as of Microsoft® Internet Explorer® 5 and later, and a solid line on downlevel browsers. |
Dashed |
Border is a dashed line as of Microsoft® Internet Explorer® 5 and later, and a solid line on downlevel browsers. |
Solid |
Border is a solid line. |
Double |
Border is a double line drawn on top of the background of the object. The sum of the two single lines and the space between equals the BorderWidth value. BorderWidth must be at least 3 pixels wide to draw a double border. |
Groove |
3-D grooved border for a sunken border appearance. |
Ridge |
3-D ridged border for a raised border appearance. |
Inset |
3-D inset border for a sunken control appearance. |
Outset |
3-D outset border for a raised control appearance. |
The BorderStyle enumeration represents the different border style options for a control.
The width of the border is controlled by using the BorderWidth property of the WebControl class.
NOTE: When using the Double style, the border width you specify must be at least 3 pixels wide to accommodate both lines and the space in between.
The following example shows how to declaratively set the BorderStyle property of a Web control at design time.
<asp:panel id = "myPanel" runat = "server"
borderstyle = "ridge"
borderwidth=3
bordercolor = "beige" />
The example below shows how to programmatically set the BorderStyle property at run time, depending on user input. The code also demonstrates how simple it is to retrieve the available system border styles and dynamically add each to a selectable list.
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
ICollection borders =
TypeDescriptor.GetConverter ( typeof ( BorderStyle ) ).GetStandardValues ( );
foreach ( BorderStyle b in borders ) {
BorderSelect.Items.Add ( b.ToString ( ) );
}
}
myTable.BorderStyle = ( BorderStyle ) BorderSelect.SelectedIndex;
}
Show me
WebControl.BorderStyle