HtmlTextWriter.RenderBeforeTag 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, ke kterým dojde před levou značkou prvku značky.
protected:
virtual System::String ^ RenderBeforeTag();
protected virtual string RenderBeforeTag();
abstract member RenderBeforeTag : unit -> string
override this.RenderBeforeTag : unit -> string
Protected Overridable Function RenderBeforeTag () As String
Návraty
Text nebo mezery, které se mají napsat před počáteční značkou prvku značky. Pokud není přepsán, null.
Příklady
Následující příklad kódu ukazuje, jak přepsat metodu RenderBeforeTag určit, zda třída odvozená z HtmlTextWriter třídy se chystá vykreslit <label> prvek. Pokud ano, RenderBeforeTag přepsání vloží počáteční značku <font> prvku bezprostředně před <label> prvek. Pokud nevykresluje <label> prvek, použije se RenderBeforeTag základní metoda.
// Override the RenderBeforeTag method to add the
// opening tag of a Font element before the
// opening tag of any Label elements rendered by this
// custom markup writer.
virtual String^ RenderBeforeTag() override
{
// Compare the TagName property value to the
// String* label to determine whether the element to
// be rendered is a Label. If it is a Label,
// the opening tag of the Font element, with a Color
// style attribute set to red, is added before
// the Label.
if ( String::Compare( TagName, "label" ) == 0 )
{
return "<font color=\"red\">";
}
// If a Label is not being rendered, use
// the base RenderBeforeTag method.
else
{
return __super::RenderBeforeTag();
}
}
// Override the RenderBeforeTag method to add the
// opening tag of a Font element before the
// opening tag of any Label elements rendered by this
// custom markup writer.
protected override string RenderBeforeTag()
{
// Compare the TagName property value to the
// string label to determine whether the element to
// be rendered is a Label. If it is a Label,
// the opening tag of the Font element, with a Color
// style attribute set to red, is added before
// the Label.
if (String.Compare(TagName, "label") == 0)
{
return "<font color=\"red\">";
}
// If a Label is not being rendered, use
// the base RenderBeforeTag method.
else
{
return base.RenderBeforeTag();
}
}
' Override the RenderBeforeTag method to add the
' opening tag of a Font element before the
' opening tag of any Label elements rendered by this
' custom markup writer.
Protected Overrides Function RenderBeforeTag() As String
' Compare the TagName property value to the
' string label to determine whether the element to
' be rendered is a Label. If it is a Label,
' the opening tag of the Font element, with a Color
' style attribute set to red, is added before
' the Label.
If String.Compare(TagName, "label") = 0 Then
Return "<font color=""red"">"
' If a Label is not being rendered, use
' the base RenderBeforeTag method.
Else
Return MyBase.RenderBeforeTag()
End If
End Function 'RenderBeforeTag
Poznámky
Metoda RenderBeforeTag může být užitečná, pokud chcete vykreslit další počáteční značky před počáteční značkou zamýšleného prvku.
Poznámky pro dědice
Implementace HtmlTextWriter třídy RenderBeforeTag() metody vrátí null. Přepište RenderBeforeTag() , pokud chcete napsat text nebo mezery před počáteční značkou prvku.