다음을 통해 공유


WebControl.Width 속성

정의

웹 서버 컨트롤의 너비를 가져오거나 설정합니다.

public:
 virtual property System::Web::UI::WebControls::Unit Width { 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 Width { get; set; }
public virtual System.Web.UI.WebControls.Unit Width { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Width : System.Web.UI.WebControls.Unit with get, set
member this.Width : System.Web.UI.WebControls.Unit with get, set
Public Overridable Property Width As Unit

속성 값

컨트롤의 너비를 나타내는 A Unit 입니다. 기본값은 Empty입니다.

특성

예외

웹 서버 컨트롤의 너비가 음수 값으로 설정되었습니다.

예제

다음 예제에서는 기본 클래스에서 WebControl 상속된 컨트롤의 Table 속성을 선언적으로 설정하는 Width 방법을 보여 줍니다.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>WebControl Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Width Property of a Web Control</h3>
    <asp:Table id="Table1" runat="server"
        CellPadding="10" GridLines="Both"
        Width="350">
 
        <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">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>WebControl Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Width Property of a Web Control</h3>
    <asp:Table id="Table1" runat="server"
        CellPadding="10" GridLines="Both"
        Width="350">
 
        <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>

설명

Width 이 속성을 사용하여 웹 서버 컨트롤의 너비를 지정합니다.

메모

이 속성은 Microsoft Internet Explorer 버전 4 이전의 브라우저에서 모든 컨트롤에 대해 렌더링되지 않습니다. 이전 브라우저에서 이 속성을 렌더링하지 않는 컨트롤에는 , HyperLinkLinkButton및 유효성 검사 컨트롤이 포함Label됩니다. DataList RadioButtonList 또한 CheckBoxList해당 속성이 로 설정된 RepeatLayout.Flow경우 RepeatLayout 이전 브라우저에서 이 속성을 렌더링하지 않습니다. 또한 이전 브라우저에서는 단위 유형 PixelPercentage 만 지원됩니다.

이 속성은 표준이 아닌 HTML이므로 웹 서버는 Microsoft Internet Explorer 버전 4 이전의 브라우저에서 이 속성과 DataGrid같은 테이블로 Table 표시되는 컨트롤을 지원하지 않습니다.

메모

속성을 기본값Pixel이 아닌 단위 형식으로 선언적으로 설정 Width 하려면 원하는 단위 형식과 관련된 새 단위 형식을 만들어야 합니다. 예를 들어 컨트롤의 Width 속성을 백분율 값 100으로 설정하려면 다음을 수행할 수 있습니다.

myWebControl.width = Unit.Percentage(100);

속성에 사용할 수 있는 단위 형식에 대한 Width 자세한 내용은 클래스를 참조하세요 Unit .

적용 대상

추가 정보