Partager via


WebControl.Height Propriété

Définition

Obtient ou définit la hauteur du contrôle serveur Web.

public:
 virtual property System::Web::UI::WebControls::Unit Height { System::Web::UI::WebControls::Unit get(); void set(System::Web::UI::WebControls::Unit value); };
[System.ComponentModel.Bindable(true)]
public virtual System.Web.UI.WebControls.Unit Height { get; set; }
public virtual System.Web.UI.WebControls.Unit Height { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Height : System.Web.UI.WebControls.Unit with get, set
member this.Height : System.Web.UI.WebControls.Unit with get, set
Public Overridable Property Height As Unit

Valeur de propriété

Qui Unit représente la hauteur du contrôle. La valeur par défaut est Empty.

Attributs

Exceptions

La hauteur a été définie sur une valeur négative.

Exemples

L’exemple suivant montre comment définir de manière déclarative la Height propriété du Table contrôle, héritée de la WebControl classe de base.

<%@ 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>
<%@ Page Language="VB" %>

<!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>

Remarques

Utilisez la Height propriété pour spécifier la hauteur du contrôle serveur Web.

Note

Cette propriété ne s’affiche pas pour tous les contrôles dans les navigateurs antérieurs à Microsoft Internet Explorer version 4. Les contrôles qui n’affichent pas cette propriété dans les navigateurs précédents incluent Label, HyperLinket LinkButtontous les contrôles de validation. Les CheckBoxListpropriétés et DataListRadioButtonList ne restituent pas cette propriété dans les navigateurs précédents lorsque leur RepeatLayout propriété est définie RepeatLayout.Flowsur . En outre, seuls les types d’unités et PixelPercentage sont pris en charge dans les navigateurs antérieurs.

Étant donné que cette propriété n’est pas standard HTML, les contrôles serveur web qui s’affichent sous forme de table, tels que Table et DataGrid, ne prennent pas en charge cette propriété dans les navigateurs antérieurs à Microsoft Internet Explorer version 4.

Note

Pour définir la Height propriété sur un type d’unité autre que la valeur par défaut Pixel, vous devez créer un nouveau type d’unité spécifique au type d’unité souhaité. Par exemple, pour définir la propriété d’un Height contrôle sur une valeur de pourcentage de 100, vous pouvez effectuer les opérations suivantes :

myWebControl.Width = Unit.Percentage(100);

Pour plus d’informations sur les types d’unités disponibles pour la Height propriété, consultez la Unit classe.

S’applique à

Voir aussi