Html32TextWriter.RenderBeforeContent Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Schreibt alle Tabstopp- oder Schriftartinformationen, die vor dem Inhalt angezeigt werden, der in einem HTML-Element enthalten ist.
protected:
override System::String ^ RenderBeforeContent();
protected override string RenderBeforeContent();
override this.RenderBeforeContent : unit -> string
Protected Overrides Function RenderBeforeContent () As String
Gibt zurück
Die schriftarteninformationen oder der zu schreibende Abstand, bevor der Inhalt des HTML-Elements gerendert wird; andernfalls, wenn keine derartigen Informationen gerendert werden sollen, null.
Beispiele
Im folgenden Codebeispiel wird das Überschreiben der RenderBeforeContent Methode veranschaulicht. Der Code überprüft, ob ein th Element gerendert wird, und überprüft dann mithilfe der SupportsBold Methode, ob das anfordernde Gerät fett formatiert werden kann. Wenn das Gerät Fettformatierung unterstützt, schreibt die RenderBeforeContent Methode das öffnende Tag eines b Elements. Wenn das Gerät keine Fettformatierung unterstützt, schreibt die RenderBeforeContent Methode das öffnende Tag eines font Elements mit einem color Attribut, das auf den Hexadezimalwert für Rot festgelegt ist.
Als Nächstes überprüft jede Methode, ob ein h4 Element gerendert wird, und verwendet dann die SupportsItalic Eigenschaft, um zu überprüfen, ob das anfordernde Gerät kursiv formatiert werden kann. Wenn das Gerät kursiv formatiert wird, schreibt die RenderBeforeContent Methode das öffnende Tag eines i Elements. Wenn das Gerät keine kursiv formatierte Formatierung unterstützt, schreibt die RenderBeforeContent Methode das öffnende Tag eines font Elements mit einem color Attribut, das auf den Hexadezimalwert für Marineblau festgelegt ist.
Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die Html32TextWriter Klasse bereitgestellt wird.
// 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();
}
' 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