Share via


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

戻り値

Boolean

RenderBeginTag メソッドの次回の呼び出し中に属性をレンダリングする場合は true。それ以外の場合は 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

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

戻り値

Boolean

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

注釈

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

こちらもご覧ください

適用対象