Pages

Friday, 14 October 2011

How to use OnTextChanged event in TextBox

TextBoxOnTextChanged.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<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>









Click Here!

No comments:

Post a Comment