TextBox TextChanged Event
textbox is an input control. this is a very useful control for html/asp.net form. naturally when someone input
some text on textbox control and submit the form, he will get output of submitted text. though asp.net is a server
side script, we can expect more advance feature from it's textbox control.
in this example we will see how textbox textchanged event work. if you change the textbox text then the textchanged event trigger and you see the submitted text on a label control. for that tutorial we set the textbox autopostback property true and text mode single line.
in this example we will see how textbox textchanged event work. if you change the textbox text then the textchanged event trigger and you see the submitted text on a label control. for that tutorial we set the textbox autopostback property true and text mode single line.
TextBoxOnTextChanged.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void TextBox1_TextChanged(object sender, System.EventArgs e) {
Label1.Text = "Text changed: " + TextBox1.Text.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>TextBox TextChanged Event</title>
</head>
<body style="padding:25px">
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
TextBox TextChanged Event
</h2>
<hr width="450" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Font-Bold="true"
Font-Names="Comic Sans MS"
ForeColor="DarkMagenta"
Font-Size="X-Large"
/>
<br /><br />
<asp:Label
ID="Label2"
runat="server"
Text="Input a color name"
AssociatedControlID="TextBox1"
Font-Bold="true"
Font-Size="Large"
ForeColor="Navy"
/>
<asp:TextBox
ID="TextBox1"
runat="server"
TextMode="SingleLine"
AutoPostBack="true"
OnTextChanged="TextBox1_TextChanged"
BackColor="PaleTurquoise"
Height="35"
Font-Bold="true"
Font-Size="Large"
Font-Names="Courier"
/>
</div>
</form>
</body>
</html>


