HtmlTextWriter.RenderBeforeContent 메서드

정의

태그 요소의 내용 앞과 여는 태그 뒤에 있는 텍스트나 공백을 씁니다.

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

반환

String

요소의 내용 앞에 있는 쓸 텍스트나 텍스트입니다. RenderBeforeContent()는 재정의되지 않으면 null을 반환합니다.

예제

다음 코드 예제에서는 클래스에서 파생된 클래스가 요소를 렌더링 <label> 하려고 하는지 여부를 확인하기 위해 메서드를 재정 RenderBeforeContentHtmlTextWriter 하는 방법을 보여줍니다. 이 경우 재정의는 RenderBeforeContent 요소의 <font> 여는 태그 바로 뒤에 요소의 여는 태그를 삽입합니다 <label> . 요소가 아닌 <label> 경우 기본 메서드가 RenderBeforeContent 사용됩니다.

// 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

설명

이 메서드는 RenderBeforeContent 내부 태그 앞에 현재 태그 요소에 자식 요소를 삽입하려는 경우에 유용할 수 있습니다.

상속자 참고

메서드의 클래스 구현이 HtmlTextWriter RenderBeforeContent() 반환됩니다 null. 여는 태그 뒤의 텍스트나 간격을 요소 콘텐츠보다 앞서 쓰려는 경우 재정 RenderBeforeContent() 의합니다.

적용 대상

추가 정보