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

Dim returnValue As String returnValue = Me.RenderBeforeContent
HTML 要素の内容の前に書き込むフォント情報または空白文字。出力するこのような情報がない場合は null 参照 (Visual Basic では Nothing)。

RenderBeforeContent メソッドをオーバーライドする方法を次のコード例に示します。このコードでは、現在レンダリングしているのが th 要素であるかどうかが確認され、次に、SupportsBold メソッドを使用して、要求元のデバイスが太字を表示できるかどうかが確認されます。デバイスが太字をサポートしている場合、RenderBeforeContent メソッドは b 要素の開始タグを書き込みます。デバイスが太字をサポートしていない場合、RenderBeforeContent メソッドは color 属性が赤の 16 進値に設定された font 要素の開始タグを書き込みます。
次に、各メソッドは、現在レンダリングしているのが h4 要素であるかどうかを確認し、SupportsItalic プロパティを使用して、要求元のデバイスが斜体を表示できるかどうかを確認します。デバイスが斜体をサポートしている場合、RenderBeforeContent メソッドは i 要素の開始タグを書き込みます。デバイスが斜体をサポートしていない場合、RenderBeforeContent メソッドは color 属性が濃紺の 16 進値に設定された font 要素の開始タグを書き込みます。
このコード例は、Html32TextWriter クラスのトピックで取り上げているコード例の一部分です。
' Override the RenderBeforeContent method to render ' styles before rendering the content of a <th> element. Protected Overrides Function RenderBeforeContent() As String ' Check the TagKey property. If its value is ' HtmlTextWriterTag.TH, check the value of the ' SupportsBold property. If true, return the ' opening tag of a <b> element; otherwise, render ' the opening tag of a <font> element with a color ' attribute set to the hexadecimal value for red. If TagKey = HtmlTextWriterTag.Th Then If (SupportsBold) Then Return "<b>" Else Return "<font color=""FF0000"">" End If End If ' Check whether the element being rendered ' is an <H4> element. If it is, check the ' value of the SupportsItalic property. ' If true, render the opening tag of the <i> element ' prior to the <H4> element's content; otherwise, ' render the opening tag of a <font> element ' with a color attribute set to the hexadecimal ' value for navy blue. If TagKey = HtmlTextWriterTag.H4 Then If (SupportsItalic) Then Return "<i>" Else Return "<font color=""000080"">" End If End If ' Call the base method. Return MyBase.RenderBeforeContent() End Function
// Override the RenderBeforeContent method to render // styles before rendering the content of a <th> element. protected override string RenderBeforeContent() { // Check the TagKey property. If its value is // HtmlTextWriterTag.TH, check the value of the // SupportsBold property. If true, return the // opening tag of a <b> element; otherwise, render // the opening tag of a <font> element with a color // attribute set to the hexadecimal value for red. if (TagKey == HtmlTextWriterTag.Th) { if (SupportsBold) return "<b>"; else return "<font color=\"FF0000\">"; } // Check whether the element being rendered // is an <H4> element. If it is, check the // value of the SupportsItalic property. // If true, render the opening tag of the <i> element // prior to the <H4> element's content; otherwise, // render the opening tag of a <font> element // with a color attribute set to the hexadecimal // value for navy blue. if (TagKey == HtmlTextWriterTag.H4) { if (SupportsItalic) return "<i>"; else return "<font color=\"000080\">"; } // Call the base method. return base.RenderBeforeContent(); }

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


- Html32TextWriter.RenderBeforeContent メソッドのページへのリンク