Export (0) Print
Expand All

WebControl.Height Property

Gets or sets the height of the Web server control.

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

public virtual Unit Height { get; set; }
/** @property */
public Unit get_Height ()

/** @property */
public void set_Height (Unit value)

public function get Height () : Unit

public function set Height (value : Unit)

Not applicable.

Property Value

A Unit that represents the height of the control. The default is Empty.

Exception typeCondition

ArgumentException

The height was set to a negative value.

Use the Height property to specify the height 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 Height property 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 Height 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 Height property, see the Unit class.

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

<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Table Property</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>Property of a Table Web Control</h3>
 
        <asp:Table id="Table1" runat="server"
            CellPadding = "10" 
            CellSpacing="0"
            GridLines="Both"
            Height="300">

            <asp:TableRow>
                <asp:TableCell>
                    Row 0, Col 0
                </asp:TableCell>
                <asp:TableCell>
                    Row 0, Col 1
                </asp:TableCell>
            </asp:TableRow>

            <asp:TableRow>
                <asp:TableCell>
                    Row 1, Col 0
                </asp:TableCell>
                <asp:TableCell>
                    Row 1, Col 1
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </div>
    </form>
</body>
</html>

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft