HtmlTextWriter.IsAttributeDefined メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ属性とその値をレンダリングするかどうかを決定します。
オーバーロード
| 名前 | 説明 |
|---|---|
| IsAttributeDefined(HtmlTextWriterAttribute) |
RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ属性とその値をレンダリングするかどうかを決定します。 |
| IsAttributeDefined(HtmlTextWriterAttribute, String) |
RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ属性とその値をレンダリングするかどうかを決定します。 |
IsAttributeDefined(HtmlTextWriterAttribute)
RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ属性とその値をレンダリングするかどうかを決定します。
protected:
bool IsAttributeDefined(System::Web::UI::HtmlTextWriterAttribute key);
protected bool IsAttributeDefined(System.Web.UI.HtmlTextWriterAttribute key);
member this.IsAttributeDefined : System.Web.UI.HtmlTextWriterAttribute -> bool
Protected Function IsAttributeDefined (key As HtmlTextWriterAttribute) As Boolean
パラメーター
マークアップ属性に関連付けられている HtmlTextWriterAttribute 。
返品
true
RenderBeginTag メソッドの次の呼び出し中に属性がレンダリングされる場合は |。それ以外の場合はfalse。
例
次のコード例は、HtmlTextWriter クラスから継承するクラスで、RenderBeginTag メソッドのオーバーライドを使用する方法を示しています。
RenderBeginTagオーバーライドは、<font>マークアップ要素がレンダリングされるかどうかをチェックします。 その場合、オーバーライドは IsAttributeDefined メソッドを呼び出して、 <font> 要素に Size 属性が含まれているかどうかを確認します。 そうでない場合、 AddAttribute メソッドは GetAttributeKey メソッドを呼び出します。このメソッドは、 Size 属性を定義し、その値を 30pt に設定します。
// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point.
if ( tagKey == HtmlTextWriterTag::Font )
{
if ( !IsAttributeDefined( HtmlTextWriterAttribute::Size ) )
{
AddAttribute( GetAttributeKey( "size" ), "30pt" );
}
}
// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point.
if (tagKey == HtmlTextWriterTag.Font)
{
if (!IsAttributeDefined(HtmlTextWriterAttribute.Size))
{
AddAttribute(GetAttributeKey("size"), "30pt");
}
}
' If the tagKey parameter is set to a <font> element
' but a size attribute is not defined on the element,
' the AddStyleAttribute method adds a size attribute
' and sets it to 30 point.
If tagKey = HtmlTextWriterTag.Font Then
If Not IsAttributeDefined(HtmlTextWriterAttribute.Size) Then
AddAttribute(GetAttributeKey("size"), "30pt")
End If
End If
注釈
HtmlTextWriterAttribute オブジェクトに割り当てられる値を取得するには、このオーバーロードの代わりに IsAttributeDefined(HtmlTextWriterAttribute, String) オーバーロードを使用します。
こちらもご覧ください
適用対象
IsAttributeDefined(HtmlTextWriterAttribute, String)
RenderBeginTag メソッドの次の呼び出し中に、指定したマークアップ属性とその値をレンダリングするかどうかを決定します。
protected:
bool IsAttributeDefined(System::Web::UI::HtmlTextWriterAttribute key, [Runtime::InteropServices::Out] System::String ^ % value);
protected bool IsAttributeDefined(System.Web.UI.HtmlTextWriterAttribute key, out string value);
member this.IsAttributeDefined : System.Web.UI.HtmlTextWriterAttribute * string -> bool
Protected Function IsAttributeDefined (key As HtmlTextWriterAttribute, ByRef value As String) As Boolean
パラメーター
マークアップ属性に関連付けられている HtmlTextWriterAttribute 。
- value
- String
属性に割り当てられた値。
返品
true
RenderBeginTag メソッドの次の呼び出し中に属性がレンダリングされる場合は |。それ以外の場合はfalse。
注釈
IsAttributeDefined メソッドがtrueを返す場合、HtmlTextWriterAttribute オブジェクトに割り当てられる値が value パラメーターで返されます。