Language

HtmlTextWriter.IsStyleAttributeDefined メソッド

定義

RenderBeginTag メソッドの次の呼び出し中にマークアップ スタイル属性をレンダリングするかどうかを決定します。

オーバーロード

名前 説明
IsStyleAttributeDefined(HtmlTextWriterStyle)

RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ スタイル属性をレンダリングするかどうかを決定します。

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ スタイル属性とその値をレンダリングするかどうかを決定します。

IsStyleAttributeDefined(HtmlTextWriterStyle)

RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ スタイル属性をレンダリングするかどうかを決定します。

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

パラメーター

key
HtmlTextWriterStyle

属性に関連付けられている HtmlTextWriterStyle 。

返品

true RenderBeginTag メソッドの次の呼び出し中に属性がレンダリングされる場合は |。それ以外の場合はfalse。

例

次のコード例は、 <label> 要素がレンダリングされているかどうかを確認する方法を示しています。 その場合、 IsStyleAttributeDefined メソッドは、 Color スタイル属性が要素に対して定義されているかどうかを確認します。 Color属性が定義されていない場合、AddStyleAttribute メソッドは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)
{
    // 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オーバーロードを使用します。

こちらもご覧ください

適用対象

IsStyleAttributeDefined(HtmlTextWriterStyle, String)

RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ スタイル属性とその値をレンダリングするかどうかを決定します。

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

パラメーター

key
HtmlTextWriterStyle

属性に関連付けられている HtmlTextWriterStyle 。

value
String

スタイル属性に割り当てられた値。

返品

true RenderBeginTag メソッドの次の呼び出し中に属性とその値がレンダリングされる場合は。それ以外の場合はfalse。

注釈

IsStyleAttributeDefined メソッドがtrueを返す場合、HtmlTextWriterStyle属性に割り当てられる値が value パラメーターで返されます。

こちらもご覧ください

適用対象