How to: Specify Multiline Input for a TextBox Web Server Control

A multiline TextBox control allows users to type information into a box that supports wordwrapping and vertical and horizontal scrolling.

To create a multiline TextBox Web server control

  1. Set the TextBox control's TextMode property to Multiline. In code, text modes are set using the TextMode enumeration.

  2. Set the size of the control by setting the following properties:

    • Width to a value in pixels, or Columns to the number of characters to display.

    • Height to a value in pixels, or Rows to the number of rows.

      Note

      The Height and Width properties do not work in browsers that do not support cascading style sheet (CSS) styles.

    Setting these properties does not limit the number of characters or rows the user can enter, only how many are displayed. The control always displays a vertical scrollbar. Height and Width take precedence over Rows and Columns.

    Note

    By default, a multiline TextBox control includes a vertical scroll bar. To hide the scroll bar, include the style attribute overflow: hidden. For example, in HTML view, the declarative syntax for the control might look as follows:

    <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 56px; OVERFLOW: hidden; POSITION: absolute; TOP: 72px" runat="server" TextMode="MultiLine"></asp:TextBox>
    
  3. Set word-wrap behavior by setting the control's Wrap property. If true, text wraps automatically (without embedding carriage-return/line feed characters). If false, the text does not wrap and the user must press ENTER to start a new line, which embeds a carriage-return/line feed character. Setting the Wrap property to false causes the control to display a horizontal scroll bar.

    Note

    The MaxLength property has no effect in a multiline text box.

See Also

Reference

TextBox Web Server Control Overview