How to: Respond to Changes in a TextBox Web Server Control
When the user leaves a TextBox Web server control after entering information, the control raises an event that you can respond to.
The TextBox Web server control does not raise an event each time the user enters a keystroke, only when the user leaves the control. You can have the TextBox control raise client-side events that you handle in client script, which can be useful for responding to individual keystrokes. For details, see Client Script in ASP.NET Web Pages.
To respond to changes in the TextBox control
By default, the TextChanged event does not immediately cause the Web Forms page to be posted to the server. Instead, the event is raised in server code the next time the form is posted. To have the TextChanged event cause an immediate posting, set the TextBox control's AutoPostBack property to true.
The following code example shows how you can respond to changes in the TextBox control. The code displays the contents of the control in a label.
User input in a Web Forms page can include potentially malicious client script. By default, the Web Forms page validates that user input does not include script or HTML elements. For more information, see How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings.