HtmlTextWriter.ExitStyle HtmlTextWriter.ExitStyle HtmlTextWriter.ExitStyle Method

定義

寫入標記項目的結尾標記,以結束指定的配置與字元格式。Writes the closing tag of a markup element to end the specified layout and character formatting.

多載

ExitStyle(Style) ExitStyle(Style) ExitStyle(Style)

寫入 <span> 項目的結尾標記,以結束指定的配置與字元格式。Writes the closing tag of a <span> element to end the specified layout and character formatting.

ExitStyle(Style, HtmlTextWriterTag) ExitStyle(Style, HtmlTextWriterTag) ExitStyle(Style, HtmlTextWriterTag)

寫入指定標記項目的結尾標記,以結束指定的版面配置與字元格式設定。Writes the closing tag of the specified markup element to end the specified layout and character formatting.

ExitStyle(Style) ExitStyle(Style) ExitStyle(Style)

寫入 <span> 項目的結尾標記,以結束指定的配置與字元格式。Writes the closing tag of a <span> element to end the specified layout and character formatting.

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

參數

style
Style Style Style

Style,指定要關閉的配置與格式。A Style that specifies the layout and formatting to close.

範例

下列程式碼範例示範TextSample如何使用名為的自訂類別(衍生WebControlEnterStyle類別),它會使用方法ForeColor將樣式套用至文字字串。The following code example demonstrates how to use a custom class named TextSample, derived from the WebControl class, that uses the EnterStyle method to apply a ForeColor style to a string of text.

方法會呈現 HTML <span style="color:Navy;">EnterStyleThe EnterStyle method renders the HTML <span style="color:Navy;">. 方法呼叫會在呈現<span>文字之後關閉元素。 ExitStyleThe ExitStyle method call closes the <span> element after the text has been rendered.

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

備註

方法的ExitStyle多載會將<span>元素的結束記號呈現在控制項的結束記號之後,關閉對應EnterStyle呼叫所開啟的專案。 ExitStyle(Style)The ExitStyle overload of the ExitStyle(Style) method renders the closing tag of a <span> element after the closing tag of the control, closing the element opened by the corresponding EnterStyle call.

ExitStyleEnterStyle方法可讓裝置介面卡或控制項建立標記,以使用指定樣式的字元格式來開始和結束區塊。The ExitStyle and EnterStyle methods allow a device adapter or control to create markup that begins and ends a block by using the character formatting of the specified style. style 在您ExitStyle于對應的方法中使用的方法中,使用與相同的值。EnterStyleUse the same value for style in the EnterStyle method that you use in the corresponding ExitStyle method.

另請參閱

ExitStyle(Style, HtmlTextWriterTag) ExitStyle(Style, HtmlTextWriterTag) ExitStyle(Style, HtmlTextWriterTag)

寫入指定標記項目的結尾標記,以結束指定的版面配置與字元格式設定。Writes the closing tag of the specified markup element to end the specified layout and character formatting.

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

參數

style
Style Style Style

Style,指定版面配置和格式設定,以停止套用輸出文字。A Style that specifies the layout and formatting to stop applying to the output text.

tag
HtmlTextWriterTag HtmlTextWriterTag HtmlTextWriterTag

HtmlTextWriterTag,指定標記項目的結尾標記,其中包含已套用指定樣式的屬性。An HtmlTextWriterTag that specifies the closing tag of the markup element that contained the attributes that applied the specified style. 這必須符合對應 EnterStyle 呼叫中所傳遞的索引鍵。This must match the key passed in the corresponding EnterStyle call.

範例

下列程式碼範例示範TextSample如何使用名為的自訂類別(衍生WebControlEnterStyle類別),它會使用方法ForeColor將樣式套用至文字字串。The following code example demonstrates how to use a custom class named TextSample, derived from the WebControl class, that uses the EnterStyle method to apply a ForeColor style to a string of text.

方法會呈現 HTML <span style="color:Navy;">EnterStyleThe EnterStyle method renders the HTML <span style="color:Navy;">. 方法呼叫會在呈現<span>文字之後關閉元素。 ExitStyleThe ExitStyle method call closes the <span> element after the text has been rendered.

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

備註

方法的ExitStyle多載會呈現在控制項的結束記號tag之後所指定之專案的結束記號,並關閉對應EnterStyle(Style, HtmlTextWriterTag)的方法呼叫所開啟的專案。 ExitStyle(Style, HtmlTextWriterTag)The ExitStyle overload of the ExitStyle(Style, HtmlTextWriterTag) method renders the closing tag of the element that is specified by tag after the closing tag of the control, closing the element that was opened by the corresponding EnterStyle(Style, HtmlTextWriterTag) method call.

ExitStyleEnterStyle方法可讓裝置介面卡或控制項建立標記,以使用指定樣式的字元格式來開始和結束區塊。The ExitStyle and EnterStyle methods allow a device adapter or control to create markup that begins and ends a block by using the character formatting of the specified style. style 在您ExitStyle于對應的方法中使用的方法中,使用與相同的值。EnterStyleUse the same value for style in the EnterStyle method that you use in the corresponding ExitStyle method.

另請參閱

適用於