TextBox doesn't fire TextChanged Event on IE 8, AutoPostback is true

Posted by MaikoID on Stack Overflow See other posts from Stack Overflow or by MaikoID
Published on 2010-06-10T18:56:53Z Indexed on 2010/06/10 19:03 UTC
Read the original article Hit count: 405

Hi guys,

I have the same thing, there are many TextBoxes with the event TextChanged set and with AutoPostback = true, and works in all browsers (Chrome, Opera, Firefox 3.6) except in IE 8, IE 6/7 I didn't test.

I don't want to put the onblur event in all my TextBoxs because there are many pages with many TextBox that use this event.

Description

I'm using a masterPage,

in the aspx i have

<asp:TextBox ID="txtCnpj" runat="server" CssClass="txt" Width="200px" onkeyup="Mascara(this,Cnpj)" onkeydown="Mascara(this,Cnpj)" MaxLength="18" AutoPostBack="true" ValidationGroup="txtCnpj" OnTextChanged="txtCnpj_TextChanged"></asp:TextBox>

in the aspx.cs

 protected void txtCnpj_TextChanged(object sender, EventArgs e)
   {

        if (CredorInvestimento.GetCredorInvestimento(txtCnpj.Text) != null)

        {

            ((TextBox)sender).Text = "";

            ((TextBox)sender).Focus();

            rfvCnpj.ErrorMessage = "Duplicado";

            Page.Validate(txtCnpj.ID);

        }

        else

            txtNome.Focus();

    }

Thanks!

ps: I really doesn't like of asp.net I spend more time fixing errors than developing new functions.

ps: sorry for my english.

ps: if i remove the onkeydown and onkeyup events the textchanged fire in IE, but i realy this events too.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about internet-explorer