TextBox OnTextChanged event
TextBox control is a input control in .net framework that lets the user input text.
this example demonstare us how asp.net textbox TextChanged event (OnTextChanged event) works.
text box TextChanged event occurs (triggers) when text changed in textbox control. TextChanged
event is asynchronius, so the event cannot be canceled. simply we can say TextChanged event occurs
when the TextBox Text property value changes.
in this example web form we create two textbox controls. first textbox control's AutoPostBack property value set to true. and we assign an OnTextChanged property value. so using this property we create a TextChanged event. when you make change textbox text, it trigger TextChanged event and another textbox control display first textbox current content.
in this example web form we create two textbox controls. first textbox control's AutoPostBack property value set to true. and we assign an OnTextChanged property value. so using this property we create a TextChanged event. when you make change textbox text, it trigger TextChanged event and another textbox control display first textbox current content.
TextBoxOnTextChanged.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void TextBox1_TextChanged(object sender, System.EventArgs e)
{
TextBox2.Text = TextBox1.Text;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to use OnTextChanged event in TextBox</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">TextBox Example: OnTextChanged</h2>
<asp:Label
ID="Label1"
runat="server"
Text="Email"
>
</asp:Label>
<asp:TextBox
ID="TextBox1"
runat="server"
AutoPostBack="true"
OnTextChanged="TextBox1_TextChanged"
>
</asp:TextBox>
<br /><br />
<asp:Label
ID="Label2"
runat="server"
Text="Confirm Email"
>
</asp:Label>
<asp:TextBox
ID="TextBox2"
runat="server"
BackColor="LightGoldenrodYellow"
ForeColor="Crimson"
>
</asp:TextBox>
</div>
</form>
</body>
</html>


