HTML 要素の内容の前および開始タグの後にテキストまたは空白文字を書き込みます。
Protected Overridable Function RenderBeforeContent() As String
[C#]
protected virtual string RenderBeforeContent();
[C++]
protected: virtual String* RenderBeforeContent();
[JScript]
protected function RenderBeforeContent() : String;
戻り値
HTML 要素の内容の前に書き込むテキストまたは空白文字。オーバーライドされない場合、このメソッドは null 参照 (Visual Basic では Nothing) を返します。
使用例
[Visual Basic, C#, C++] RenderBeforeContent メソッドをオーバーライドし、カスタム MyHtmlTextWriter
オブジェクトが HTML の <label> 要素を出力しているかどうかをチェックする例を次に示します。出力している場合は、 RenderBeforeContent を使用して、ラベルの開始タグの直後に、HTML の <font> 要素の開始タグを挿入します。 <label> 要素でない場合は、 RenderBeforeContent メソッドの基本機能が使用されます。
' Override the RenderBeforeContent method to write
' a font element that applies red to the text in a Label element.
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Function RenderBeforeContent() As String
' Check to determine whether the element being rendered
' is a label element. If so, render the opening tag
' of the font element; otherwise, call the base method.
If TagKey = HtmlTextWriterTag.Label Then
Return "<font color=""red"">"
Else
Return MyBase.RenderBeforeContent()
End If
End Function 'RenderBeforeContent
[C#]
// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override string RenderBeforeContent()
{
// Check to determine whether the element being rendered
// is a label element. If so, render the opening tag
// of the font element; otherwise, call the base method.
if(TagKey == HtmlTextWriterTag.Label)
{
return "<font color=\"red\">";
}
else
{
return base.RenderBeforeContent();
}
}
[C++]
// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.
protected:
[System::Security::Permissions::PermissionSet(System::Security::Permissions::SecurityAction::Demand, Name="FullTrust")]
String* RenderBeforeContent() {
// Check to determine whether the element being rendered
// is a label element. If so, render the opening tag
// of the font element; otherwise, call the base method.
if (TagKey == HtmlTextWriterTag::Label) {
return S"<font color=\"red\">";
} else {
return __super::RenderBeforeContent();
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ
参照
HtmlTextWriter クラス | HtmlTextWriter メンバ | System.Web.UI 名前空間