Share via


HtmlTextWriter.ExitStyle Método

Definición

Escribe la etiqueta de cierre del elemento de marcado para finalizar el diseño y el formato de carácter especificados.

Sobrecargas

ExitStyle(Style)

Escribe la etiqueta de cierre del elemento <span> para finalizar el diseño y el formato de carácter especificados.

ExitStyle(Style, HtmlTextWriterTag)

Escribe la etiqueta de cierre del elemento de marcado especificado para finalizar el diseño especificado y el formato de caracteres.

ExitStyle(Style)

Escribe la etiqueta de cierre del elemento <span> para finalizar el diseño y el formato de carácter 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

Style que especifica el diseño y el formato para el cierre.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar una clase personalizada denominada TextSample, derivada de la WebControl clase , que usa el EnterStyle método para aplicar un ForeColor estilo a una cadena de texto.

El EnterStyle método representa el código HTML <span style="color:Navy;">. La ExitStyle llamada al método cierra el <span> elemento después de representar el texto.

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

Comentarios

La ExitStyle sobrecarga del ExitStyle(Style) método representa la etiqueta de cierre de un <span> elemento después de la etiqueta de cierre del control, cerrando el elemento abierto por la llamada correspondiente EnterStyle .

Los ExitStyle métodos y EnterStyle permiten que un adaptador de dispositivo o un control creen marcado que comience y termine un bloque mediante el formato de caracteres del estilo especificado. Use el mismo valor para style en el EnterStyle método que se usa en el método correspondiente ExitStyle .

Consulte también

Se aplica a

ExitStyle(Style, HtmlTextWriterTag)

Escribe la etiqueta de cierre del elemento de marcado especificado para finalizar el diseño especificado y el formato de caracteres.

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

Style que especifica el diseño y formato para dejar de aplicar al texto de salida.

tag
HtmlTextWriterTag

HtmlTextWriterTag que especifica la etiqueta de cierre del elemento de marcado que contenía los atributos que se aplicaban el estilo especificado. Debe coincidir con la clave pasada en la llamada EnterStyle correspondiente.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar una clase personalizada denominada TextSample, derivada de la WebControl clase , que usa el EnterStyle método para aplicar un ForeColor estilo a una cadena de texto.

El EnterStyle método representa el código HTML <span style="color:Navy;">. La ExitStyle llamada al método cierra el <span> elemento después de representar el texto.

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

Comentarios

La ExitStyle sobrecarga del ExitStyle(Style, HtmlTextWriterTag) método representa la etiqueta de cierre del elemento especificado tag después de la etiqueta de cierre del control, cerrando el elemento que abrió la llamada al método correspondiente EnterStyle(Style, HtmlTextWriterTag) .

Los ExitStyle métodos y EnterStyle permiten que un adaptador de dispositivo o un control creen marcado que comience y termine un bloque mediante el formato de caracteres del estilo especificado. Use el mismo valor para style en el EnterStyle método que se usa en el método correspondiente ExitStyle .

Consulte también

Se aplica a