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.


<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)


protected void page_Load(object sender, EventArgs e)




1 comment:

  1. Sir i am making a EDIT PROFILE page,in which in page load event i have shown username,email in textboxes,with update and cancel buttons with i want to let user type new value in tht same textbox and save it,but its not working,previoualy values are storing[while successfully workin when using new textboxes along with them to update.]kindly show such program to edit a page.