Control.IsLiteralContent 메서드

정의

서버 컨트롤에 리터럴 내용만 저장되어 있는지 확인합니다.

protected:
 bool IsLiteralContent();
protected bool IsLiteralContent ();
member this.IsLiteralContent : unit -> bool
Protected Function IsLiteralContent () As Boolean

반환

Boolean

서버 컨트롤에 리터럴 내용만 들어 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.

예제

다음 예제에서는 서버 컨트롤이 포함된 페이지가 다시 게시되었는지 여부를 확인합니다. 있는 경우 메서드를 IsLiteralContent 호출하여 컨트롤에 리터럴 콘텐츠만 포함되는지 아니면 다른 서버 컨트롤에 대한 부모 컨트롤인지 확인합니다. 리터럴 콘텐츠만 포함하는 경우 해당 콘텐츠를 UniqueID 나타내는 속성 LiteralControl 이 응답에 기록됩니다.

// Override the OnLoad method to check if the 
// page that uses this control has posted back.
// If so, check whether this controls contains
// only literal content, and if it does,
// it gets the UniqueID property and writes it
// to the page. Otherwise, it writes a message
// that the control contains more than literal content.
protected override void OnLoad(EventArgs e)
{
        if (Page.IsPostBack)
        {
                String s;

                if (this.IsLiteralContent())
                {
                        s = Controls[0].UniqueID;
                        Context.Response.Write(s);
                }
                else
                {
                        Context.Response.Write(
                                "The control contains more than literal content.");
                }
        }
}
' Override the OnLoad method to check if the 
' page that uses this control has posted back.
' If so, check whether this controls contains
' only literal content, and if it does,
' it gets the UniqueID property and writes it
' to the page. Otherwise, it writes a message
' that the control contains more than literal content.
Overrides Protected Sub OnLoad(ByVal e As EventArgs)

   If Page.IsPostBack = True Then
      Dim s As String

      If Me.IsLiteralContent() = True Then
         s = Controls(0).UniqueID
         Context.Response.Write(s)
      Else
         Context.Response.Write( _
         "The control contains more than literal content.")
      End If
   End If
End Sub

설명

이 메서드가 반환 true되면 서버 컨트롤의 컬렉션은 단일 리터럴 컨트롤을 보유합니다.

적용 대상

추가 정보