다음을 통해 공유


ITextControl.Text 속성

정의

컨트롤의 텍스트 내용을 가져오거나 설정합니다.

public:
 property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public string Text { get; set; }
member this.Text : string with get, set
Public Property Text As String

속성 값

컨트롤의 텍스트 내용입니다.

예제

다음 코드 예제에서는 인터페이스를 구현 하는 사용자 지정 컨트롤을 ITextControl 보여 줍니다. 속성에 Text 전달되는 경우 null 기본값이 속성에 할당됩니다.


public class CustomTextControl : Control, ITextControl
{
    private string _text;

    public CustomTextControl()
    {
    }

    public string Text
    {
        get
        {
            return _text;
        }
        set
        {
            if (value != null)
            {
                _text = value;
            }
            else
            {
                _text = "No Value.";
            }
        }
    }

    // Provide the remaining code to implement a text control.
}

Public Class CustomTextControl
    Inherits System.Web.UI.Control
    Implements System.Web.UI.ITextControl

    Private _text As String

    Public Property Text() As String Implements System.Web.UI.ITextControl.Text
        Get
            Return _text
        End Get
        Set(ByVal value As String)
            If (value <> Nothing) Then
                _text = value
            Else
                _text = "No Value."
            End If
        End Set
    End Property

    ' Provide the remaining code to implement a text control.
End Class

설명

속성을 Text 프로그래밍 방식으로 또는 사용자 입력을 통해 설정할 수 있습니다.

주의

이 인터페이스를 구현하는 컨트롤을 사용하여 사용자 입력을 표시할 수 있습니다. 사용자 입력을 표시하기 전에 입력에서 실행 스크립트 또는 SQL 문과 같은 악의적인 클라이언트 스크립트를 확인해야 합니다. ASP.NET 사용자 입력에서 스크립트 및 HTML을 차단하는 입력 요청 유효성 검사 기능을 제공합니다. 사용자 입력을 평가하기 위해 유효성 검사 서버 컨트롤도 제공됩니다. 자세한 내용은 유효성 검사 서버 컨트롤 구문을 참조하세요.

적용 대상