Skip to content

<Textbox>

The Textbox tag renders as a single-line text input box at run time. You will probably use it most often in your forms — it is the standard control for entering names, addresses, and other single-line data.

Example

html
<AddForm>
  ...
  <table>
    <tr>
      <td>
        <Label For="txtFirstName" Text="First Name" />
        <Textbox Id="txtFirstName" DataField="FirstName" DataType="String" />
      </td>
    </tr>
    <tr>
      <td>
        <Label For="txtLastName" Text="Last Name" />
        <Textbox Id="txtLastName" DataField="LastName" DataType="String" />
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <AddButton Text="Add"/>&nbsp;<CancelButton Text="Cancel"/>
      </td>
    </tr>
  </table>
</AddForm>

Properties

PropertyValuesDefaultDescription
ID *stringUnique identifier for the control within the form
DataFieldstringParameter name for data binding to your form's data commands
DataTypeString Int32 Int64 Boolean more...StringDatabase type for data commands
AccessKeystringKeyboard shortcut character (e.g. F for Alt+F)
CssClassstringCSS class name(s) for styling the control
EnabledTrue FalseTrueWhen False, the control is disabled (grayed out and not interactive). Different from ReadOnly, which still allows focus and selection
HeightsizeHeight of the control
HtmlEncodeTrue FalseFalseHTML-encodes content before sending to the SubmitCommand
MaxLengthintegerMaximum number of characters allowed
NullableTrue FalseFalseReturns DBNull when the control is blank or whitespace
PlaceholderstringHint text displayed when the control is empty
ReadOnlyTrue FalseFalsePrevents the user from changing the contents
StylestringInline CSS (e.g. color: red; border: solid 1px black;)
TabIndexintegerTab order for keyboard navigation
ToolTipstringText displayed on mouse hover
VisibleTrue FalseTrueShows or hides the control
WidthsizeWidth of the control

* Required property

Deprecated Properties

These properties use ASP.NET inline styling and are no longer recommended for modern web development. Use the CssClass property to apply CSS classes or the Style property for inline CSS instead.

PropertyValuesDescription
BackColorcolor name | #ddddddBackground color of the control
BorderColorcolor name | #ddddddBorder color of the control
BorderStyleNotSet None Dotted Dashed Solid Double Groove Ridge Inset OutsetBorder style of the control
BorderWidthsizeBorder width of the control
Font-BoldTrue FalseBold text
Font-ItalicTrue FalseItalic text
Font-NamesstringFont family name
Font-OverlineTrue FalseOverline text decoration
Font-SizeXX-Small X-Small Small Medium Large X-Large XX-Large or sizeFont size
Font-StrikeoutTrue FalseStrikethrough text decoration
Font-UnderlineTrue FalseUnderline text decoration
ForeColorcolor name | #ddddddText color of the control

Property Details

  • ID: Name, consisting of letters and numbers, beginning with a letter, that uniquely identifies the control within the form.

  • DataField: Name of the parameter in the <SubmitCommand> which will be filled with this control's data when the form is submitted and/or the parameter in the <SelectCommand> which will supply this control's data when the form is loaded. This attribute is required if the control will participate in operations with your form's data commands.

  • DataType: The type of data this control is supplying to the data commands. This is a Database type. This attribute is required if the control will participate in operations with your form's data commands.

  • HtmlEncode: When set to True, the content of the control will be HTML-encoded before sending it to the SubmitCommand for processing. This can help protect against scripting attacks but will also enlarge the size of the text that is saved — for instance, < becomes &lt;.

  • Nullable: If True, the control will return a DBNull value if the control is blank or contains just whitespace. If a DBNull value is passed to the control, the control will be set to an empty string.

  • Placeholder: The value will be displayed in the textbox when it is empty, providing explanatory text prior to user input. For instance, a contact form's Email textbox might use "Enter your email address" or simply "Email" as the Placeholder. When the user tabs into the control, the text disappears. If the user tabs out without entering anything, the placeholder text re-appears. This is not a default value and will not be sent to the database.