HtmlTextWriter.ExitStyle Método

Definição

Grava a marca de fechamento de um elemento de marcação para encerrar o layout e a formatação de caracteres especificados.

Sobrecargas

ExitStyle(Style)

Grava a marca de fechamento de um elemento <span> para encerrar o layout e a formatação de caracteres especificados.

ExitStyle(Style, HtmlTextWriterTag)

Grava a marca de fechamento do elemento de marcação especificado para encerrar o layout e a formatação de caracteres especificados.

ExitStyle(Style)

Grava a marca de fechamento de um elemento <span> para encerrar o layout e a formatação de caracteres especificados.

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

Parâmetros

style
Style

Um Style que especifica o layout e a formatação para fechar.

Exemplos

O exemplo de código a seguir demonstra como usar uma classe personalizada chamada TextSample, derivada da WebControl classe, que usa o EnterStyle método para aplicar um ForeColor estilo a uma cadeia de caracteres de texto.

O EnterStyle método renderiza o HTML <span style="color:Navy;">. A ExitStyle chamada de método fecha o <span> elemento depois que o texto é renderizado.

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

Comentários

A ExitStyle sobrecarga do ExitStyle(Style) método renderiza a marca de fechamento de um <span> elemento após a marca de fechamento do controle, fechando o elemento aberto pela chamada correspondente EnterStyle .

Os ExitStyle métodos e EnterStyle os métodos permitem que um adaptador ou controle de dispositivo crie marcação que começa e termina um bloco usando a formatação de caracteres do estilo especificado. Use o mesmo valor no style EnterStyle método usado no método correspondente ExitStyle .

Confira também

Aplica-se a

ExitStyle(Style, HtmlTextWriterTag)

Grava a marca de fechamento do elemento de marcação especificado para encerrar o layout e a formatação de caracteres especificados.

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

Parâmetros

style
Style

Um Style que especifica o layout e a formatação cuja aplicação ao texto de saída deve ser interrompida.

tag
HtmlTextWriterTag

Um HtmlTextWriterTag que especifica a marca de fechamento do elemento de marcação que continha os atributos que aplicaram o estilo especificado. Isso deve corresponder à chave passada na chamada EnterStyle correspondente.

Exemplos

O exemplo de código a seguir demonstra como usar uma classe personalizada chamada TextSample, derivada da WebControl classe, que usa o EnterStyle método para aplicar um ForeColor estilo a uma cadeia de caracteres de texto.

O EnterStyle método renderiza o HTML <span style="color:Navy;">. A ExitStyle chamada de método fecha o <span> elemento depois que o texto é renderizado.

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

Comentários

A ExitStyle sobrecarga do ExitStyle(Style, HtmlTextWriterTag) método renderiza a marca de fechamento do elemento especificado tag após a marca de fechamento do controle, fechando o elemento que foi aberto pela chamada de método correspondente EnterStyle(Style, HtmlTextWriterTag) .

Os ExitStyle métodos e EnterStyle os métodos permitem que um adaptador ou controle de dispositivo crie marcação que começa e termina um bloco usando a formatação de caracteres do estilo especificado. Use o mesmo valor no style EnterStyle método usado no método correspondente ExitStyle .

Confira também

Aplica-se a