共用方式為


WebControl.Height 屬性

定義

取得或設定網頁伺服器控制的高度。

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

屬性值

A Unit 代表控制點的高度。 預設值為 Empty

屬性

例外狀況

高度設定為負值。

範例

以下範例說明如何宣告式設定HeightWebControl基底類別繼承的控制屬性Table

<%@ 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>

備註

使用屬性 Height 來指定網頁伺服器控制項的高度。

備註

此屬性不適用於 Microsoft Internet Explorer 4 之前的所有瀏覽器控制項。 早期瀏覽器中不呈現此屬性的控制項包括 LabelHyperLinkLinkButton及任何驗證控制項。 CheckBoxList當 的 RadioButtonListDataList屬性設為 RepeatLayout.Flow時,在早期瀏覽器RepeatLayout中 , 以及 並不會呈現此屬性。 此外,早期瀏覽器僅支援 和 Percentage 的單位類型Pixel

由於此屬性為非標準 HTML,顯示為表格的網頁伺服器控制項(如 TableDataGrid)在 Microsoft Internet Explorer 4 版本之前的瀏覽器中不支援此屬性。

備註

若要將屬性設定 Height 為非預設的 Pixel單位類型,必須建立一個與你想要的單位類型相關的新單位類型。 例如,要將控制項 Height 屬性設定為 100 的百分比值,你可以這樣做:

myWebControl.Width = Unit.Percentage(100);

欲了解更多該物業可用Height單位類型的資訊,請參閱該類別。Unit

適用於

另請參閱