편집

다음을 통해 공유


ITextControl Interface

Definition

Defines the interface a control implements to get or set its text content.

public interface class ITextControl
public interface ITextControl
type ITextControl = interface
Public Interface ITextControl
Derived

Examples

The following code example shows a custom control that implements the ITextControl interface. A default value is assigned to the Text property if null is passed to the property.


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

Remarks

The ITextControl interface defines the Text property a control implements to allow the getting or setting of its text content. The Text property can be set programmatically or through user input.

Caution

A control implementing this interface can be used to display user input. Before displaying user input, the input must be checked for malicious client script, such as executable script or SQL statements. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Validation Server Control Syntax.

Properties

Text

Gets or sets the text content of a control.

Applies to