HtmlTextWriter.ExitStyle Metodo

Definizione

Scrive il tag di chiusura di un elemento di markup per terminare il layout e la formattazione dei caratteri specificati.

Overload

ExitStyle(Style)

Scrive il tag di chiusura di un elemento <span> per terminare il layout e la formattazione dei caratteri specificati.

ExitStyle(Style, HtmlTextWriterTag)

Scrive il tag di chiusura dell'elemento di markup specificato per terminare il layout e la formattazione dei caratteri specificati.

ExitStyle(Style)

Scrive il tag di chiusura di un elemento <span> per terminare il layout e la formattazione dei caratteri specificati.

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)

Parametri

style
Style

Oggetto Style che specifica il layout e la formattazione da chiudere.

Esempio

Nell'esempio WebControl di codice seguente viene illustrato come usare una classe personalizzata denominata TextSample, derivata dalla classe, che usa il EnterStyle metodo per applicare uno ForeColor stile a una stringa di testo.

Il EnterStyle metodo esegue il rendering dell'oggetto HTML <span style="color:Navy;">. La ExitStyle chiamata al metodo chiude l'elemento <span> dopo il rendering del testo.

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

Commenti

L'overload ExitStyle del metodo esegue il rendering del ExitStyle(Style) tag di chiusura di un <span> elemento dopo il tag di chiusura del controllo, chiudendo l'elemento aperto dalla chiamata corrispondente EnterStyle .

I ExitStyle metodi e EnterStyle consentono a un adattatore dispositivo o a un controllo di creare markup che inizia e termina un blocco usando la formattazione dei caratteri dello stile specificato. Utilizzare lo stesso valore per style nel EnterStyle metodo usato nel metodo corrispondente ExitStyle .

Vedi anche

Si applica a

ExitStyle(Style, HtmlTextWriterTag)

Scrive il tag di chiusura dell'elemento di markup specificato per terminare il layout e la formattazione dei caratteri specificati.

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)

Parametri

style
Style

Oggetto Style che specifica il layout e la formattazione per arrestare l'applicazione al testo di output.

tag
HtmlTextWriterTag

Oggetto HtmlTextWriterTag che specifica il tag di chiusura dell'elemento di markup contenente gli attributi che applicavano lo stile specificato. Deve corrispondere alla chiave passata alla chiamata EnterStyle corrispondente.

Esempio

Nell'esempio WebControl di codice seguente viene illustrato come usare una classe personalizzata denominata TextSample, derivata dalla classe, che usa il EnterStyle metodo per applicare uno ForeColor stile a una stringa di testo.

Il EnterStyle metodo esegue il rendering dell'oggetto HTML <span style="color:Navy;">. La ExitStyle chiamata al metodo chiude l'elemento <span> dopo il rendering del testo.

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

Commenti

L'overload ExitStyle del ExitStyle(Style, HtmlTextWriterTag) metodo esegue il rendering del tag di chiusura dell'elemento specificato tag dopo il tag di chiusura del controllo, chiudendo l'elemento aperto dalla chiamata del metodo corrispondente EnterStyle(Style, HtmlTextWriterTag) .

I ExitStyle metodi e EnterStyle consentono a un adattatore dispositivo o a un controllo di creare markup che inizia e termina un blocco usando la formattazione dei caratteri dello stile specificato. Utilizzare lo stesso valore per style nel EnterStyle metodo usato nel metodo corrispondente ExitStyle .

Vedi anche

Si applica a