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

Protected Overridable Function OnStyleAttributeRender ( _ name As String, _ value As String, _ key As HtmlTextWriterStyle _ ) As Boolean
Dim name As String Dim value As String Dim key As HtmlTextWriterStyle Dim returnValue As Boolean returnValue = Me.OnStyleAttributeRender(name, value, key)
protected virtual bool OnStyleAttributeRender ( string name, string value, HtmlTextWriterStyle key )
protected: virtual bool OnStyleAttributeRender ( String^ name, String^ value, HtmlTextWriterStyle key )
protected function OnStyleAttributeRender ( name : String, value : String, key : HtmlTextWriterStyle ) : boolean
戻り値
常に true。

HtmlTextWriter クラスで実装されている OnStyleAttributeRender メソッドは、常に true を返します。OnStyleAttributeRender オーバーライドで、ページにスタイル属性を出力するかどうかを確認できます。
継承時の注意 HtmlTextWriter クラスから継承する場合は、OnStyleAttributeRender メソッドをオーバーライドして false を返し、スタイル属性をまったく出力しない、特定の要素に出力しない、または特定のマークアップでは出力しないようにできます。たとえば、HtmlTextWriter から派生したオブジェクトが color 属性を <p> 要素に出力しないようにするには、OnStyleAttributeRender をオーバーライドして、name から color が渡され、TagName プロパティ値が p のときに false を返すようにできます。
OnStyleAttributeRender メソッドをオーバーライドする方法を次のコード例に示します。Color スタイル属性が出力されても、Color 値が purple ではない場合、OnStyleAttributeRender オーバーライドは AddStyleAttribute メソッドを使用し、Color 属性を purple に設定します。
' If a color style attribute is to be rendered, ' compare its value to purple. If it is not set to ' purple, add the style attribute and set the value ' to purple, then return false. Protected Overrides Function OnStyleAttributeRender(name As String, _ value As String, _ key As HtmlTextWriterStyle) _ As Boolean If key = HtmlTextWriterStyle.Color Then If [String].Compare(value, "purple") <> 0 Then AddStyleAttribute("color", "purple") Return False End If End If ' If the style attribute is not a color attribute, ' use the base functionality of the ' OnStyleAttributeRender method. Return MyBase.OnStyleAttributeRender(name, value, key) End Function 'OnStyleAttributeRender
// If a color style attribute is to be rendered, // compare its value to purple. If it is not set to // purple, add the style attribute and set the value // to purple, then return false. protected override bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key) { if (key == HtmlTextWriterStyle.Color) { if (string.Compare(value, "purple") != 0) { AddStyleAttribute("color", "purple"); return false; } } // If the style attribute is not a color attribute, // use the base functionality of the // OnStyleAttributeRender method. return base.OnStyleAttributeRender(name, value, key); }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlTextWriter.OnStyleAttributeRender メソッドを検索する場合は、下記のリンクをクリックしてください。

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