HtmlTextWriter.IsStyleAttributeDefined HtmlTextWriter.IsStyleAttributeDefined HtmlTextWriter.IsStyleAttributeDefined HtmlTextWriter.IsStyleAttributeDefined Method

定義

判斷標記樣式屬性是否會在 RenderBeginTag 方法的下一個呼叫期間呈現。Determines whether a markup style attribute is rendered during the next call to the RenderBeginTag method.

多載

IsStyleAttributeDefined(HtmlTextWriterStyle) IsStyleAttributeDefined(HtmlTextWriterStyle) IsStyleAttributeDefined(HtmlTextWriterStyle) IsStyleAttributeDefined(HtmlTextWriterStyle)

判斷指定的標記樣式屬性是否會在 RenderBeginTag 方法的下一個呼叫期間呈現。Determines whether the specified markup style attribute is rendered during the next call to the RenderBeginTag method.

IsStyleAttributeDefined(HtmlTextWriterStyle, String) IsStyleAttributeDefined(HtmlTextWriterStyle, String) IsStyleAttributeDefined(HtmlTextWriterStyle, String) IsStyleAttributeDefined(HtmlTextWriterStyle, String)

判斷指定的標記樣式屬性以及該屬性的值是否會在 RenderBeginTag 方法的下一個呼叫期間呈現。Determines whether the specified markup style attribute and its value are rendered during the next call to the RenderBeginTag method.

IsStyleAttributeDefined(HtmlTextWriterStyle) IsStyleAttributeDefined(HtmlTextWriterStyle) IsStyleAttributeDefined(HtmlTextWriterStyle) IsStyleAttributeDefined(HtmlTextWriterStyle)

判斷指定的標記樣式屬性是否會在 RenderBeginTag 方法的下一個呼叫期間呈現。Determines whether the specified markup style attribute is rendered during the next call to the RenderBeginTag method.

protected:
 bool IsStyleAttributeDefined(System::Web::UI::HtmlTextWriterStyle key);
protected bool IsStyleAttributeDefined (System.Web.UI.HtmlTextWriterStyle key);
member this.IsStyleAttributeDefined : System.Web.UI.HtmlTextWriterStyle -> bool
Protected Function IsStyleAttributeDefined (key As HtmlTextWriterStyle) As Boolean

參數

傳回

如果此屬性將在 RenderBeginTag 方法的下一個呼叫期間呈現,則為 true,否則為 falsetrue if the attribute will be rendered during the next call to the RenderBeginTag method; otherwise, false.

範例

下列程式碼範例示範如何檢查是否<label>正在呈現專案。The following code example shows how to check whether a <label> element is being rendered. 若是如此,此IsStyleAttributeDefined方法會檢查Color是否已在元素上定義樣式屬性。If so, the IsStyleAttributeDefined method checks whether a Color style attribute has been defined on the element. 如果尚未定義AddStyleAttribute Color red屬性,則方法會定義屬性,並將其值設定為。 ColorIf the Color attribute has not been defined, the AddStyleAttribute method defines the Color attribute and sets its value to red.

// If the markup element being rendered is a Label,
// render the opening tag of a <Font> element before it.
if ( tagKey == HtmlTextWriterTag::Label )
{
   
   // Check whether a Color style attribute is
   // included on the Label. If not, use the
   // AddStyleAttribute and GetStyleName methods to add one
   // and set its value to red.
   if (  !IsStyleAttributeDefined( HtmlTextWriterStyle::Color ) )
   {
      AddStyleAttribute( GetStyleName( HtmlTextWriterStyle::Color ), "red" );
   }

// If the markup element being rendered is a Label,
// render the opening tag of a Font element before it.
if (tagKey == HtmlTextWriterTag.Label)
{
    // Check whether a Color style attribute is 
    // included on the Label. If not, use the
    // AddStyleAttribute and GetStyleName methods to add one
    // and set its value to red.
    if (!IsStyleAttributeDefined(HtmlTextWriterStyle.Color))
    {
        AddStyleAttribute(GetStyleName(HtmlTextWriterStyle.Color), "red");
    }
' If the markup element being rendered is a Label,
' render the opening tag of a Font element before it.
If tagKey = HtmlTextWriterTag.Label Then
    ' Check whether a Color style attribute is 
    ' included on the Label. If not, use the
    ' AddStyleAttribute and GetStyleName methods to add one
    ' and set its value to red.
    If Not IsStyleAttributeDefined(HtmlTextWriterStyle.Color) Then
        AddStyleAttribute(GetStyleName(HtmlTextWriterStyle.Color), "red")
    End If

備註

若要取得將使用指定的樣式屬性轉譯的值,請使用IsStyleAttributeDefined(HtmlTextWriterStyle, String) IsStyleAttributeDefined方法的多載。To get the value that will be rendered with the specified style attribute, use the IsStyleAttributeDefined(HtmlTextWriterStyle, String) overload of the IsStyleAttributeDefined method.

另請參閱

IsStyleAttributeDefined(HtmlTextWriterStyle, String) IsStyleAttributeDefined(HtmlTextWriterStyle, String) IsStyleAttributeDefined(HtmlTextWriterStyle, String) IsStyleAttributeDefined(HtmlTextWriterStyle, String)

判斷指定的標記樣式屬性以及該屬性的值是否會在 RenderBeginTag 方法的下一個呼叫期間呈現。Determines whether the specified markup style attribute and its value are rendered during the next call to the RenderBeginTag method.

protected:
 bool IsStyleAttributeDefined(System::Web::UI::HtmlTextWriterStyle key, [Runtime::InteropServices::Out] System::String ^ % value);
protected bool IsStyleAttributeDefined (System.Web.UI.HtmlTextWriterStyle key, out string value);
member this.IsStyleAttributeDefined : System.Web.UI.HtmlTextWriterStyle * string -> bool
Protected Function IsStyleAttributeDefined (key As HtmlTextWriterStyle, ByRef value As String) As Boolean

參數

value
String String String String

指派給樣式屬性的值。The value assigned to the style attribute.

傳回

如果此屬性以及屬性值將在 RenderBeginTag 方法的下一個呼叫期間呈現,則為 true,否則為 falsetrue if the attribute and its value will be rendered during the next call to the RenderBeginTag method; otherwise, false.

備註

IsStyleAttributeDefined如果HtmlTextWriterStyle value方法傳回,則會在參數中傳回要指派給true屬性的值。If the IsStyleAttributeDefined method returns true, the value to be assigned to the HtmlTextWriterStyle attribute is returned in the value parameter.

另請參閱

適用於