Click here to Skip to main content
15,174,182 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used a TextBox as Password input, which is associated with a warning message for incorrect input. For re-entering password into the TextBox (firing the textbox_TextChanged event), I want to the warning message invisible. I put the textbox in the UpdatePanel also. But it still does not work. My code is below:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" >
        <asp:Label ID="lblPassword" runat="server" Text="Administrator Password:"
            Height="24px" Width="170px" style="font-weight: 700"></asp:Label> &nbsp;
        <asp:TextBox ID="TextBoxPassword" runat="server" Height="24px" Width="192px"
            Tooltip = "Enter Your Password (Case Senssitive)"
            AutoPostBack="True"  ></asp:TextBox>
        <asp:Label ID="lblPasswordWarning" runat="server"
            Text="Incorrect Password, Re-enter again" Visible="False"
            Height="31px" Width="170px" style="color: #FF3300;"></asp:Label>

protected void TextBoxPassword_TextChanged(object sender, EventArgs e) {
    if (TextBoxPassword.Text.Length > 5) {
        btnOK.Enabled = true;

How can the textBox_TextChanged event get fired? Thanks.
Thanks7872 31-Oct-13 8:36am
You should do this at Client side using JavaScript.
IpsitaMishra 31-Oct-13 8:41am
why donot you use onkeypress event of textbox
Stephen Hewison 31-Oct-13 8:50am
I agree this should be done client side. Normally when server events don't fire it's because you forget to rewire the event when the form is posted back.
Nicholas Marty 31-Oct-13 10:32am
Have you considered using a Validator (e.g. CustomValidator) for checking the password?
If you wan't to stop them entering an empty password there is an RequiredFieldValidator etc.
Usually those Validators (except the Custom one) also have Client-Side validation (in addition to server side)

1 solution

You are missing the trigger:

    <asp:asyncpostbacktrigger controlid="TextBoxPassword" eventname="TextChanged" xmlns:asp="#unknown" />
[no name] 31-Oct-13 10:18am
To contracting1992: Tried yours but got asp:asyncpostbacktrigger not supported. Any additional recommendation? Thanks.
To Rohan: I also agree that a JavaScript should be used. But I haven't found a good sample on it. Could you provide additional help if you can? Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900