HtmlTextWriter.RenderAfterTag Metoda

Definicja

Zapisuje wszelkie odstępy lub tekst występujący po tagu zamykającym dla elementu znaczników.

protected:
 virtual System::String ^ RenderAfterTag();
protected virtual string RenderAfterTag ();
abstract member RenderAfterTag : unit -> string
override this.RenderAfterTag : unit -> string
Protected Overridable Function RenderAfterTag () As String

Zwraca

String

Odstępy lub tekst do zapisania po zamykającym tagu elementu.

Przykłady

W poniższym przykładzie kodu pokazano, jak zastąpić metodę RenderAfterTag w celu określenia, czy klasa pochodząca z HtmlTextWriter klasy renderuje <label> element. Jeśli tak, RenderAfterTag przesłonięcie wstawia tag <font> zamykający elementu bezpośrednio po elemecie <label> . Jeśli nie <label> jest to element, zostanie użyta metoda podstawowa RenderAfterTag .

// Override the RenderAfterTag method to add the
// closing tag of the Font element after the
// closing tag of a Label element has been rendered.
virtual String^ RenderAfterTag() 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 closing tag of a Font element is rendered
   // after the closing tag of the Label element.
   if ( String::Compare( TagName, "label" ) == 0 )
   {
      return "</font>";
   }
   // If a Label is not being rendered, use
   // the base RenderAfterTag method.
   else
   {
      return __super::RenderAfterTag();
   }
}
// Override the RenderAfterTag method to add the 
// closing tag of the Font element after the 
// closing tag of a Label element has been rendered.
protected override string RenderAfterTag()
{
    // 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 closing tag of a Font element is rendered
    // after the closing tag of the Label element.
    if (String.Compare(TagName, "label") == 0)
    {
        return "</font>";
    }
    // If a Label is not being rendered, use 
        // the base RenderAfterTag method.
    else
    {
        return base.RenderAfterTag();
    }
}
    ' Override the RenderAfterTag method to add the 
    ' closing tag of the Font element after the 
    ' closing tag of a Label element has been rendered.
    Protected Overrides Function RenderAfterTag() 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 closing tag of a Font element is rendered
        ' after the closing tag of the Label element.
        If String.Compare(TagName, "label") = 0 Then
            Return "</font>"
            ' If a Label is not being rendered, use 
            ' the base RenderAfterTag method.
        Else
            Return MyBase.RenderAfterTag()
        End If
    End Function 'RenderAfterTag
End Class

Uwagi

Metoda może być przydatna RenderAfterTag , jeśli chcesz renderować dodatkowe tagi zamykające po tagu elementu.

Uwagi dotyczące dziedziczenia

Implementacja HtmlTextWriter RenderAfterTag() klasy metody zwraca wartość null. Zastąpij RenderAfterTag() , jeśli chcesz napisać tekst lub odstępy po tagu zamykającym element.

Dotyczy

Zobacz też