ASP.NET Web Forms TextBox

This is an input control which is used to take user input. To create TextBox either we can write code or use the drag and drop facility of visual studio IDE.

This is server side control, asp provides own tag to create it. The example is given below.

Server renders it as the HTML control and produces the following code to the browser.

This control has its own properties that are tabled below.

PropertyDescription
AccessKeyIt is used to set keyboard shortcut for the control.
TabIndexThe tab order of the control.
BackColorIt is used to set background color of the control.
BorderColorIt is used to set border color of the control.
BorderWidthIt is used to set width of border of the control.
FontIt is used to set font for the control text.
ForeColorIt is used to set color of the control text.
TextIt is used to set text to be shown for the control.
ToolTipIt displays the text when mouse is over the control.
VisibleTo set visibility of control on the form.
HeightIt is used to set height of the control.
WidthIt is used to set width of the control.
MaxLengthIt is used to set maximum number of characters that can be entered.
ReadonlyIt is used to make control readonly.

Example

// WebControls.aspx

Code Behind

// WebControls.aspx.cs

This is a property window of the TextBox control.

ASP Textbox 1

Output:

It produces the following output.

ASP Textbox 2

It displays user input, when user submits the input to the server. The following screen shot taking and showing user input.

ASP Textbox 3
Next TopicASP.NET Button