HtmlTextWriter.GetAttributeKey メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim attrName As String Dim returnValue As HtmlTextWriterAttribute returnValue = Me.GetAttributeKey(attrName)
戻り値
指定した属性の HtmlTextWriterAttribute 列挙値。属性が列挙値のメンバでない場合は HtmlTextWriterAttribute。

attrName が null 参照 (Visual Basic では Nothing) または空の文字列 ("") の場合や、属性名のテーブルに見つからない場合は、HtmlTextWriterAttribute オブジェクトとして型指定された値 -1 が返されます。

RenderBeginTag メソッドをオーバーライドする HtmlTextWriter クラスから派生したクラスを使用する方法を次のコード例に示します。このオーバーライドは、tagKey が Font フィールドと等しいかどうかをチェックします。これは、<font> マークアップ要素が出力されることを示します。等しい場合、このオーバーライドは IsAttributeDefined メソッドを呼び出して、<font> 要素に Size 属性が含まれているかどうかをチェックします。IsAttributeDefined が false を返した場合、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
// 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 call adds a size attribute // and sets it to 30 point. if (tagKey.Equals(HtmlTextWriterTag.Font)) { if (!(IsAttributeDefined(HtmlTextWriterAttribute.Size))) { AddAttribute(GetAttributeKey("size"), "30pt"); } }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


HtmlTextWriter クラス
HtmlTextWriter メンバ
System.Web.UI 名前空間
TextWriter
HtmlTextWriterAttribute
RenderBeginTag
IsAttributeDefined
AddAttribute
Weblioに収録されているすべての辞書からHtmlTextWriter.GetAttributeKey メソッドを検索する場合は、下記のリンクをクリックしてください。

- HtmlTextWriter.GetAttributeKey メソッドのページへのリンク