次の方法で共有


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 インターフェイスを実装するカスタム コントロールを示しています。 nullがプロパティに渡された場合、既定値は Text プロパティに割り当てられます。


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 をブロックする入力要求検証機能を提供します。 検証サーバー コントロールは、ユーザー入力を評価するためにも用意されています。 詳細については、「 検証サーバーコントロールの構文」を参照してください

適用対象