WebControl.Style 속성

정의

웹 서버 컨트롤의 외부 태그에서 스타일 특성으로 렌더링할 텍스트 특성의 컬렉션을 가져옵니다.

public:
 property System::Web::UI::CssStyleCollection ^ Style { System::Web::UI::CssStyleCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.CssStyleCollection Style { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Style : System.Web.UI.CssStyleCollection
Public ReadOnly Property Style As CssStyleCollection

속성 값

CssStyleCollection

웹 서버 컨트롤의 외부 태그에서 렌더링할 HTML 스타일 특성을 포함하는 CssStyleCollection입니다.

특성

예제

다음 예제를 사용 하는 방법을 합니다 Style 속성을 숨기 거 나 표시를 Label 페이지에 컨트롤입니다.

참고

다음 코드 샘플 단일 파일 코드 모델을 사용 하 고 코드 숨김 파일에 직접 복사 하는 경우 제대로 작동 하지 않을 수 있습니다. 이 코드 샘플.aspx 확장명이 있는 빈 텍스트 파일에 복사 해야 합니다. Web Forms 코드 모델에 대 한 자세한 내용은 참조 하세요. ASP.NET Web Forms 페이지 코드 모델합니다.

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

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

<script runat="server">
 
    void Button1_Click(Object sender, EventArgs e)
    {
        if (Label1.Style["visibility"] == "hidden")
            Label1.Style["visibility"] = "show";
        else
            Label1.Style["visibility"] = "hidden";
    }
 
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Style Property of a Web Control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
        <h3>Style Property of a Web Control</h3>
 
        <asp:Label id="Label1" Text="This is a label control." 
            BorderStyle="Solid" runat="server"/>

        <p>
            <asp:Button id="Button1" 
                Text="Click to hide or unhide the label"
                OnClick="Button1_Click" runat="server"/>
        </p>

    </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">
 
    Sub Button1_Click(sender As Object, e As EventArgs)
        If Label1.Style("visibility") = "hidden" Then
            Label1.Style("visibility") = "show"
        Else
            Label1.Style("visibility") = "hidden"
        End If
    End Sub
 
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Style Property Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
        <h3>Style Property of a Web Control</h3>
 
        <asp:Label id="Label1" Text="This is a label control." 
            BorderStyle="Solid" runat="server"/>

        <p>
            <asp:Button id="Button1" Text="Click to hide or unhide the label"
                OnClick="Button1_Click" runat="server"/>
        </p>

    </div>
    </form>
</body>
</html>

설명

사용 된 Style 웹 서버 컨트롤의 외부 태그에서 렌더링할 스타일 특성을 관리 하는 컬렉션입니다. 이 속성은 모든 컨트롤에 대 한 모든 브라우저에서 렌더링 됩니다.

참고

스타일 특성을 지원 하지 않는 브라우저는 렌더링된 된 HTML을 무시 합니다.

강력한 형식의 스타일 속성을 통해 설정 된 스타일 값 (예를 들어 BackColor="Red")이이 컬렉션에 있는 해당 값을 자동으로 덮어씁니다.

이 컬렉션에 설정 된 값 강력한 형식의 스타일 속성에 의해 자동으로 반영 되지 않습니다.

적용 대상

추가 정보