HtmlTextWriter.RenderBeforeContent Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Zapíše jakýkoli text nebo mezery před obsahem a za levou značku prvku značky.
protected:
virtual System::String ^ RenderBeforeContent();
protected virtual string RenderBeforeContent();
abstract member RenderBeforeContent : unit -> string
override this.RenderBeforeContent : unit -> string
Protected Overridable Function RenderBeforeContent () As String
Návraty
Text nebo mezery k zápisu před obsahem prvku. Pokud není přepsáno, RenderBeforeContent() vrátí hodnotu null.
Příklady
Následující příklad kódu ukazuje, jak přepsat metodu RenderBeforeContent určit, zda třída odvozená z HtmlTextWriter třídy se chystá vykreslit <label> prvek. Pokud ano, RenderBeforeContent přepsání vloží levou <font> značku prvku bezprostředně za levou značku <label> prvku. Pokud se nejedná o <label> prvek, RenderBeforeContent použije se základní metoda.
// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.
virtual String^ RenderBeforeContent() override
{
// 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 __super::RenderBeforeContent();
}
}
// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.
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();
}
}
' Override the RenderBeforeContent method to write
' a font element that applies red to the text in a Label element.
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
Poznámky
Metoda RenderBeforeContent může být užitečná, pokud chcete vložit podřízené prvky do aktuálního prvku revize před vnitřní značky.
Poznámky pro dědice
Implementace HtmlTextWriter třídy RenderBeforeContent() metody vrátí null. Přepište RenderBeforeContent() , pokud chcete za levou značku napsat text nebo mezery, ale před obsahem elementu.