views:

289

answers:

0

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.