Skip to main content

ASPxTextBox Class

A text box editor.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web


public class ASPxTextBox :


The ASPxTextBox control allows end users to enter text in a single line.


Create a Text Box

Design Time

The ASPxTextBox control is available on the DX.23.2: Common Controls toolbox tab in the Microsoft Visual Studio IDE.

TextBox in Toolbox

Drag the control onto a form and customize the control’s settings, or paste the control markup in the page’s source code.


To properly function, DevExpress controls require that special modules, handlers and options are registered in the the Web.config file. Switch the Microsoft Visual Studio IDE to the Design tab to automatically update the Web.config file with the required DevExpress information.

<dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Text="Test text" Width="170px">

Run Time

using DevExpress.Web;
protected void Page_Load(object sender, EventArgs e)
ASPxTextBox textBox = new ASPxTextBox();
textBox.ID = "ASPxTextBox1";
textBox.Width = Unit.Pixel(170);
textBox.Text = "Test text";

Client-Side API

The ASPxTextBox‘s client-side API is implemented with JavaScript language and exposed by the ASPxClientTextBox object.


Available by default.

Client object type


Access name




Data-Bound Mode

You can bind the text box control to data fields in a data source.

<dx:ASPxTextBox ID="ASPxTextBox" runat="server" Width="100%" Value='<%# Bind("Name") %>' >

More details | See demo

Native Render

Set the Native property to true to render the ASPxTextBox as a native HTML text input element. This reduces the amount of generated HTML code and improves the editor’s performance. In native mode, the text box’s appearance depends on how the client browser renders native HTML elements.

<dx:ASPxTextBox ID="TextBox" runat="server" Native="True" Width="166" Text="TextBox">

Native Mode | See demo

Null Prompt Text

The text box displays a prompt text if its value is null and if the editor is not focused. The prompt text disappears when the editor receives focus. Use the NullText property to define the prompt text.

<dx:ASPxTextBox ID="TextBox" runat="server" NullText="Enter your name..." Width="166" Text="TextBox">

See demo

Masked Input

The text box editor allows you to use masks (MaskSettings when you edit the editor. Use masks to specify format to enter a value to the editor.

<dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="100%" Caption="Zip Code">
    <MaskSettings Mask="00000" ErrorText="Please input missing digits" />

Learn more | See demo

Display Format

Use the DisplayFormatString property to format display values in the text box.

<dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Text="123456" DisplayFormatString="[ 00 - 00 - 00 ]" Width="100%" />

TextBox - DisplayFormatString Property

See demo

Built-in Validation

The text box allows you to validate its data both on the client and server side.

<dx:ASPxTextBox runat="server" Width="100%" ID="NameTextBox" OnValidation="NameTextBox_Validation">
    <ValidationSettings SetFocusOnError="True" 
      ErrorText="Name must be at least <br /> two characters long" Display="Dynamic" ErrorTextPosition="Bottom">
        <RequiredField IsRequired="True" ErrorText="Name is required" />
    <ClientSideEvents Validation="onNameValidation" />
    <InvalidStyle BackColor="LightPink" />
function onNameValidation(s, e) {
    var name = e.value;
    if (name == null)
    if (name.length < 2)
        e.isValid = false;
protected void NameTextBox_Validation(object sender, ValidationEventArgs e) {
    if ((e.Value as string).Length < 2)
         e.IsValid = false;

Learn more | See demo

See Also