Export (0) Print
Expand All

WebControl.Width Property

Gets or sets the width of the Web server control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

abstract Width : Unit with get, set 
override Width : Unit with get, set

Property Value

Type: System.Web.UI.WebControls.Unit
A Unit that represents the width of the control. The default is Empty.

ExceptionCondition
ArgumentException

The width of the Web server control was set to a negative value.

Use the Width property to specify the width of the Web server control.

NoteNote

This property does not render for all controls in browsers earlier than Microsoft Internet Explorer version 4. Controls that do not render this property in earlier browsers include Label, HyperLink, LinkButton, and any validation controls. The CheckBoxList, RadioButtonList and DataList also do not render this property in earlier browsers when their RepeatLayout property is set to RepeatLayout.Flow. Furthermore, only unit types of Pixel and Percentage are supported in earlier browsers.

Because this property is nonstandard HTML, Web server controls that display as a table, such as Table and DataGrid, do not support this property in browsers earlier than Microsoft Internet Explorer version 4.

NoteNote

To set the Width property declaratively to a unit type other than the default of Pixel, you must create a new unit type specific to the unit type you want. For example, to set a control's Width property to a percentage value of 100, you could do the following:

myWebControl.width = Unit.Percentage(100);

For more information on the unit types available for the Width property, see the Unit class.

The following example illustrates how to declaratively set the Width property of the Table control, inherited from the WebControl base class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Show:
© 2015 Microsoft