RSS

Search Engine

Tuesday, May 18, 2010

ASP.Net TextBox Control

The ASP.Net TextBox control enables you to display an input type textbox control on the ASP.net web page that allows the users to enter their input in text mode and submit it to the server side using ASP.Net Button control. You can get or set the value to or from the ASP.Net Textbox control using its Text property programmatically. It support both plain text as well as HTML code or scripts that can be submitted to the server side or can be displayed in the multiline enabled textbox control. The HTML code and CSS support of textbox control enables you to customize the styles of the text entered through it. This feature also leads to security vulnerabilities. That is why it is recommended to validate the input entered by the user into the ASP.Net textbox control to prevent the execution of malicious client side scripts. You can also attach the client side events to the textbox control that can be used to validate the user input.

Properties of ASP.Net TextBox Control

The TextBox control consists of two types of properties such as CSS based style properties that allow you to customize the look and feel of the control as well as the input text entered by the users and the other type of properties handles the behavior of textbox.

Following are the commonly used properties of ASP.Net Textbox control:

1. AutoCompleteType: It accepts the predefined keyword for example FirstName, LastName, Email etc. that provides the functionality to display the autocomplete list under the textbox control to enter the input from the previously entered values for the textboxes with same AutoCompleteType.

2. AutoPostBack: It is a Boolean type property that enables or disables the auto postback functionality of text box control that posts the web page to server when user enters the input into the textbox control jumps to the another control.

3. CausesValidation: It is also a Boolean type property that enables or disables the validation controls associated with the textbox control to validate the input.

4. Columns: It accepts the integer value to set the width of the multiline textbox. The integer value enables the control to accommodate the specified number of characters horizontally.

5. MaxLength: It also accepts the integer value that restricts the control to reject the characters exceeding the specified value. This property works with single line textbox control

6. ReadOnly: It is a Boolean property that enables or disables the textbox control whether to allow the user to change its value or not.

7. Rows: It accepts the integer value to set the height of the multiline textbox. The integer value enables the control to accommodate the specified number of characters vertically.

8. Text: It accepts the text value that you want to display in the textbox control initially. You can assign the value dynamically as well as get the value entered by the user through the Text property of ASP.Net textbox control.

9. TextMode: It accepts the predefined keyword such as SingleLine, MultiLine or Password that adjusts the behavior of the textbox control on the web page.

10. ValidationGroup: It accepts the name of the validation group to which it belongs that validates the user input when a postback occurs.

Other than the above properties it also contains CSS based properties that allow you to customize the style of the textbox and the input text. These properties include BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Font-Bold, Font-Italic, Font-Names, Font-Overline, Font-Size, Font-StrikeOut, Font-Underline, ForeColor, Height and Width.

ASP.Net TextBox Events

The textbox control provides OnTextChanged event that can be used to read and validate the user input entered into the textbox.

0 comments:

Post a Comment