Thursday, July 29, 2010

TextBox Control

by Emmaneale Mendu, Web Developer

One of the main features of Web pages is to offer forms that end users can use to submit their information for collection. The TextBox server control is one of the most used controls in this space. As its name suggests, the control provides a text box on the form that enables the end user to input text. This server control is an input Text Field on Webpage where the user can enter Text.

Important Properties:

TextMode Property:

  • SingleLine(Default) - This property is used to enter text on one line
  • MultiLine - This property is used to enter text in multiline
  • Password - This property is used to hide text for example while checking authentication fields.

Example as shown below:

Design ViewPage View


  • ID - Using this property we can refer Control from container, the microsoft giving unique value to all form controls.
  • AutoPostBack - This property get or set the events automatically to server.

Example ::

<asp:textbox autopostback="true/false" id="TextBox1" runat="server"></asp:TextBox>

  • BackColor - Using this property we can set object background color, this property returns color pre-defined structure.

Example ::

TextBox1.BackColor = System.Drawing.Color.FromArgb(236, 233, 216);
TextBox2.BackColor = System.Drawing.Color.FromArgb(161,86,153);

  • ForeColor - Using this property we can set object data color, this property returns color pre-defined structure.

Example:

<asp:TextBox ID="TextBox2" ForeColor="Red" runat="server" /><br /><br />
<asp:TextBox ID="TextBox3" ForeColor="DarkGreen" runat="server" /><br /≶<br />
<asp:TextBox ID="TextBox4" ForeColor="Goldenrod" runat="server" /><br /><br />
<asp:TextBox ID="TextBox5" ForeColor="Firebrick" runat="server" /><br /><br />

Using the Focus() method

The Focus() method enables you to dynamically place the end user's cursor in an appointed form element(not just the TextBox control, but in any of the server controls derived from the webcontrol class)

Example:

protected void page_Load(object sender, EventArgs e)

{

TextBox1.Focus();

}

0 comments:

Post a Comment

Related Posts with Thumbnails