![]() ![]() | ||
As with Windows forms, the TextBox Web server control is an input control that lets you enter text. Here is the class hierarchy of this class:
Object Control WebControl TextBox
This control is usually converted into a standard HTML text field, using an HTML <input> element with the type attribute set to "text" to create a text field—here's an example:
<input name="TextBox1" type="text" id="TextBox1" style="Z-INDEX: 104; LEFT: 239px; POSITION: absolute; TOP: 127px" />
You can set the style of the text box using the TextMode property. By default, the TextMode property is set to SingleLine to create a single-line HTML text field, but it also can be set to MultiLine for a multiline text box, or Password to create a password control. As with other Web server controls, these also are supported with HTML controls; a multiline text box, for example, is actually an HTML text area control. Here's an example created by VB .NET:
<textarea name="TextBox2" id="TextBox2" style="height:74px;width:157px; Z-INDEX: 103; LEFT: 233px; POSITION: absolute; TOP: 117px"></textarea>
You set the display width of a text box with its Columns property. And if it's a multiline text box, the display height is set with the Rows property. As we'll see in this chapter, using Web server text boxes is much like using Windows forms text boxes. Of course, the properties, methods, and events are often different to fit the Web browser environment, but the basic functionality is similar. For example, to recover the text in a text box, you can use its Text property in Visual Basic code; it has a TextChanged event to handle the case where the user changes the text in the text box.
![]() ![]() | ||