The TextBox control generates single and multiline text boxes.
Required properties are noted in boldface type.
<asp:TextBox id=value runat="SERVER" AutoPostBack="True|False" Colums="characters" MaxLength="characters" Rows="rows" Text="text" TextMode="Single | Multiline | Password" Wrap="True|False" OnTextChanged="OnTextChangedMethod" > </asp:TextBox>
Property | Description |
---|---|
(Base control properties) | The properties defined in Base Web Control Properties. |
AutoPostBack | True if client-side changes in the control automatically cause a postback to the server; false otherwise. The default is false. |
Columns | The width of the control in characters. This property differs from the Width, which sets the absolute width of the control independent of the character spacing. |
MaxLength | The maximum number of characters allowed within text box. This property has no effect unless the TextMode property is set to SingleLine or Password. |
Rows | Number of rows within the text box. This property has no effect unless the TextMode property is set to MultiLine. |
Text | The text that the user has entered into the box. |
TextMode | Indicates whether the text box is in single-line, multiline, or password mode. Possible values are Single, MultiLine, and Password. |
Wrap | Indicates whether text should wrap around as users type text into a multiline control. This property has no effect unless the TextMode property is set to MultiLine. |
Event (and paramters) | Description |
---|---|
OnTextChanged(Object sender, EventArgs e) | Raised on the server when the contents of the text box change. This event does not cause the Web Forms page to be posted to the server unless the AutoPostBack property is set to true.
The e events argument object has no properties. |
The following shows a sample declaration for a TextBox control in an .aspx file. The control is multiline with a maximum of 10 lines displayed. The control will display in Arial font if the browser supports fonts for controls. The method txtLogin_Changed is bound to the control's TextChanged method.
<asp:TextBox runat=server id="txtLogin" Text="" Font_Face="Arial" Font_Size="3" BackColor="lightblue" TextMode="MultiLine" Heigth=10 OnTextChanged="txtLogin_Changed()" />
See Also
Web Forms Controls by Function | Applying Styles to Web Forms Controls | Setting Fonts in Web Forms Controls | Creating Event-Handling Methods for Web Forms Controls | Creating Web Forms Controls Programmatically