Back to Devexpress

TextBox

aspnet-8996-aspnet-mvc-extensions-data-editors-extensions-textbox.md

latest2.1 KB
Original Source

TextBox

  • Aug 08, 2019
  • 3 minutes to read

TextBox represents a single-line input control that allows end-users to enter text.

To learn more about TextBox and see it in action, refer to our online demos.

Implementation Details

TextBox is realized by the TextBoxExtension class. Its instance can be accessed via the ExtensionsFactory.TextBox helper method, which is used to add a TextBox extension to a view. This method’s parameter provides access to the TextBox ‘s settings implemented by the TextBoxSettings class, allowing you to fully customize the extension.

TextBox ‘s client counterpart is represented by the ASPxClientTextBox object.

Declaration

TextBox can be added to a view in the following manner.

View code (ASPX):

csharp
<% 
    Html.DevExpress().TextBox(
        settings => {
            settings.Name = "textBox1";

            settings.Width = 170;
            settings.Properties.DisplayFormatString = "[00 - 00 - 00]";
            settings.Text = "123456";
        }
    )
    .Render();
%>

View code (Razor):

csharp
@Html.DevExpress().TextBox(
    settings => {
        settings.Name = "textBox1";

        settings.Width = 170;
        settings.Properties.DisplayFormatString = "[00 - 00 - 00]";
        settings.Text = "123456";
    }).GetHtml()

Note

The Partial View should contain only the extension’s code.

The code result is demonstrated in the image below.

Main Features

  • Data-Bound Mode

  • Native Rendering

  • Null Prompt Text

  • Masked Input

  • Display Formatting

  • Built-in Validation

  • Full-Featured Client-Side API