HtmlTextWriter.EnterStyle 메서드

정의

지정한 스타일의 레이아웃과 문자 형식을 구현하는 특성이 포함된 태그 요소의 여는 태그를 씁니다.

오버로드

EnterStyle(Style)

지정한 스타일의 레이아웃과 문자 형식을 구현하는 특성이 포함된 <span> 요소의 여는 태그를 씁니다.

EnterStyle(Style, HtmlTextWriterTag)

지정한 스타일의 레이아웃과 문자 형식을 구현하는 특성이 포함된 태그 요소의 여는 태그를 씁니다.

EnterStyle(Style)

지정한 스타일의 레이아웃과 문자 형식을 구현하는 특성이 포함된 <span> 요소의 여는 태그를 씁니다.

public:
 virtual void EnterStyle(System::Web::UI::WebControls::Style ^ style);
public virtual void EnterStyle (System.Web.UI.WebControls.Style style);
abstract member EnterStyle : System.Web.UI.WebControls.Style -> unit
override this.EnterStyle : System.Web.UI.WebControls.Style -> unit
Public Overridable Sub EnterStyle (style As Style)

매개 변수

style
Style

태그 블록에 적용을 시작할 레이아웃과 형식을 지정하는 Style입니다.

예제

다음 코드 예제에서는 메서드를 사용하여 텍스트 문자열에 스타일을 적용하는 클래스에서 WebControl 파생된 명명TextSample된 사용자 지정 클래스를 ForeColor 사용하는 EnterStyle 방법을 보여 줍니다.

이 메서드는 EnterStyle HTML <span style="color:Navy;">을 렌더링합니다. 메서드 호출은 ExitStyle 텍스트가 <span> 렌더링된 후 요소를 닫습니다.

Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Security.Permissions
Imports System.Drawing

' Create a custom class, named TextSample, that renders
' its Text property with styles applied by the
' EnterStyle and ExitStyle methods. 
Namespace AspNet.Samples

    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class TextSample
        Inherits Control

        ' Create an instance of the Style class.
        Private textStyle As Style = New Style()
        Private textMessage As String

        ' Create a Text property.
        Public Property Text() As String
            Get
                Return textMessage
            End Get
            Set(ByVal value As String)
                textMessage = value
            End Set
        End Property


        Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
            ' Set the value of the Text property.
            textMessage = "Hello, World!"

            ' Set the Style object's ForeColor
            ' property to Navy.
            textStyle.ForeColor = Color.Navy

            ' Render the Text property with the style.
            writer.WriteLine("The text property styled: ")
            writer.EnterStyle(textStyle)
            writer.Write(Text)
            writer.ExitStyle(textStyle)

            ' Use the WriteBreak method twice to render
            ' an empty line between the lines of rendered text.
            writer.WriteBreak()
            writer.WriteBreak()

            ' Render the Text property without the style.
            writer.WriteLine("The Text property unstyled: ")
            writer.Write(Text)
        End Sub
    End Class
End Namespace

설명

이 메서드를 EnterStyle 사용하여 배경색 또는 테두리 너비와 같은 스타일을 태그 블록에 적용합니다.

합니다 EnterStyleExitStyle 메서드를 지정된 된 스타일의 문자 서식을 사용 하는 태그를 만들려면 디바이스 어댑터 또는 컨트롤을 사용 합니다. 해당 ExitStyle 메서드에서 사용하는 메서드에 EnterStyle 대해 동일한 값을 style 사용합니다.

EnterStyle 메서드의 EnterStyle(Style) 오버로드는 요소의 여는 태그를 <span> 렌더링합니다. 그런 다음 이 메서드는 필요한 특성 및 스타일 특성을 요소의 여는 <span> 태그에 추가하여 개체에 지정된 Style 설정을 표시합니다. 특성 및 스타일 특성을 포함하도록 다른 태그 요소를 렌더링하려면 오버로드를 EnterStyle(Style, HtmlTextWriterTag) 사용합니다.

추가 정보

적용 대상

EnterStyle(Style, HtmlTextWriterTag)

지정한 스타일의 레이아웃과 문자 형식을 구현하는 특성이 포함된 태그 요소의 여는 태그를 씁니다.

public:
 virtual void EnterStyle(System::Web::UI::WebControls::Style ^ style, System::Web::UI::HtmlTextWriterTag tag);
public virtual void EnterStyle (System.Web.UI.WebControls.Style style, System.Web.UI.HtmlTextWriterTag tag);
abstract member EnterStyle : System.Web.UI.WebControls.Style * System.Web.UI.HtmlTextWriterTag -> unit
override this.EnterStyle : System.Web.UI.WebControls.Style * System.Web.UI.HtmlTextWriterTag -> unit
Public Overridable Sub EnterStyle (style As Style, tag As HtmlTextWriterTag)

매개 변수

style
Style

태그 블록에 적용을 시작할 레이아웃과 형식을 지정하는 Style입니다.

tag
HtmlTextWriterTag

style에 지정된 스타일 개체가 포함될 태그 요소의 여는 태그를 지정하는 HtmlTextWriterTag입니다.

예제

다음 코드 예제에서는 메서드를 사용하여 텍스트 문자열에 스타일을 적용하는 클래스에서 WebControl 파생된 명명TextSample된 사용자 지정 클래스를 ForeColor 사용하는 EnterStyle 방법을 보여 줍니다.

이 메서드는 EnterStyle HTML <span style="color:Navy;">을 렌더링합니다. 메서드 호출은 ExitStyle 텍스트가 <span> 렌더링된 후 요소를 닫습니다.

Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Security.Permissions
Imports System.Drawing

' Create a custom class, named TextSample, that renders
' its Text property with styles applied by the
' EnterStyle and ExitStyle methods. 
Namespace AspNet.Samples

    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class TextSample
        Inherits Control

        ' Create an instance of the Style class.
        Private textStyle As Style = New Style()
        Private textMessage As String

        ' Create a Text property.
        Public Property Text() As String
            Get
                Return textMessage
            End Get
            Set(ByVal value As String)
                textMessage = value
            End Set
        End Property


        Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
            ' Set the value of the Text property.
            textMessage = "Hello, World!"

            ' Set the Style object's ForeColor
            ' property to Navy.
            textStyle.ForeColor = Color.Navy

            ' Render the Text property with the style.
            writer.WriteLine("The text property styled: ")
            writer.EnterStyle(textStyle)
            writer.Write(Text)
            writer.ExitStyle(textStyle)

            ' Use the WriteBreak method twice to render
            ' an empty line between the lines of rendered text.
            writer.WriteBreak()
            writer.WriteBreak()

            ' Render the Text property without the style.
            writer.WriteLine("The Text property unstyled: ")
            writer.Write(Text)
        End Sub
    End Class
End Namespace

설명

이 메서드를 EnterStyle 사용하여 배경색 또는 테두리 너비와 같은 스타일을 태그 블록에 적용합니다.

합니다 EnterStyleExitStyle 메서드를 지정된 된 스타일의 문자 서식을 사용 하는 태그를 만들려면 디바이스 어댑터 또는 컨트롤을 사용 합니다. 해당 ExitStyle 메서드에서 사용하는 메서드에 EnterStyle 대해 동일한 값을 style 사용합니다.

EnterStyle 메서드의 EnterStyle(Style, HtmlTextWriterTag) 오버로드는 매개 변수로 지정된 요소의 여는 태그를 tag 렌더링합니다. 그런 다음, 메서드는 EnterStyle(Style, HtmlTextWriterTag) 필요한 특성 및 스타일 특성을 요소의 여는 태그에 추가하여 개체에 지정된 Style 설정을 표시합니다. 오버로드를 EnterStyle(Style) 사용하여 요소의 여는 태그를 렌더링합니다 <span> .

추가 정보

적용 대상