System.Web.UI.WebControls Namespace WebControl Class
Sets or retrieves the border width of a Web control.
Inline |
<asp:control BorderWidth = intUnit ... > |
Script |
WebControl.BorderWidth [ = intUnit ] |
intUnit |
Floating-point number and a valid .NET length Unit: either an absolute units designator ( cm, mm, in, pt, pc, or px ) or a relative units designator ( em or ex ). |
This property is read/write with no default value.
BorderWidth is used to specify how wide the border of a Web server control is rendered. This property is set with a Unit object that must evaluate to a positive value.
Note that this property will render only for certain controls.
In general, only controls that render as an HTML <table> or <div> element ( block objects ) can display a border color, such as Table, Panel, DataGrid, Calendar, etc.
It will also work for list controls that have their RepeatLayout property set to Table, such as the CheckBoxList, RadioButtonList and DataList.
NOTE: All unit types are supported as of Microsoft® Internet Explorer® 5 and later. BorderWidth can only be expressed in pixels, though, for browsers earlier than version 5.
The following example shows how to declaratively set the BorderWidth 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 BorderWidth property at run time, depending on user input.
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
for ( int i=5; i<=30; i+=5 ) {
widthSelect.Items.Add ( i.ToString ( ) );
}
widthSelect.SelectedIndex = 2;
}
myTable.BorderWidth = int.Parse ( widthSelect.SelectedItem.Text );
}
Show me
The following example demonstrates use of the BorderWidth property with client-side DHTML events to dynamically modify a control's border width. This sample uses calls to an embedded stylesheet to change the BorderWidth in response to mouse events.
Show me
WebControl Members Style Base Web Control Properties