Types of Web Controls
Web controls fall into five categories: display, input, selection, validation, and special purpose.
Input Controls
Input controls let the user enter data into the application. ASP.NET supports only one input web control: the TextBox. The TextBox behaves like a single-line or multiline edit control, depending on the value of its TextMode property. Its simplified syntax is:
<asp:textbox id="SingleText" text="Single Line TextBox" runat="server" /> <asp:textbox id="PasswordText" text="Password" textmode="Password" runat="server" /> <asp:textbox id="MultiText" text="Multiline TextBox" textmode="Multiline" runat="server" />
The TextBox control can then be accessed programmatically with a code fragment like:
SingleText.Text = "Hello ASP.NET"
PasswordText.Attributes("Value") = "New Password"
MultiText.Text = "Multiline TextBox can hold many lines of text"Note that the text of a TextBox control using the Password text mode cannot be set directly.
The appearance of input controls when rendered to the browser is shown in Figure 5-1. The code used to generate this figure is shown in Example 5-5.

Figure 5-1. Rendering of input controls
Example 5-5. InputControls.aspx
<%@ Page Language="vb" %> <html> <head> <title>Input Control Example</title> <script runat="server"> Sub Page_Load( ) SingleText.Text = "Hello ASP.NET" PasswordText.Attributes("Value") = "New Password" MultiText.Text ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access