TextBox.TextChanged event not firing!

G

Guest

Hi guys

I'm trying to get ASP.NET to do something when someone starts typing in my
textbox, but it doesn't want to fire the codebehind!

I've got AutoPostBack set to to True on my textbox, and the following wireup
in my code-behind...

this.txtMyTextBox.TextChanged += new System.EventHandler(this.TextChange);

TextChange function looks something like...

private void TextChange
{
Response.Write("test!");
}

But when I type in the text box nothing happens! What have I missed?!

Cheers


Dan
 
G

Grant Merwitz

Try set your AutoPostBack to true.

You do realise however, this will cause the page to post back and reload.
Not a very nice user experience.

Unless you loading some other data on the page, i would suggest you use
javascript for this
 
G

Guest

My AutoPostBack is set to True, it still doesn't work.

This is an intranet application, so I wanted to see what the speed was like
- might be okay, might not :)

Any other suggestions?
 
G

Grant Merwitz

Works fine for me:

Try attached

dhnriverside said:
My AutoPostBack is set to True, it still doesn't work.

This is an intranet application, so I wanted to see what the speed was
like
- might be okay, might not :)

Any other suggestions?
 
G

Guest

sorry Grant.... attached? Can't see any attachments? Using the Microsoft web
reader thingy.... can you email me? dan at musoswire.com

Ta mate
 
Joined
Jan 28, 2008
Messages
2
Reaction score
0
I have a similar problem. I have a made a web-page with a textbox, a calendar and a radiobuttonlist (I have also tried dropdownlist.)
Testing: I do changes in the textbox and chooses another date in the calendar. Then it's ok. The event textbox.textchanged is trigged. But if I do change the textbox and then chooses another radiobutten (or dropdown) the textbox.textchanged event is NOT trigged. Why?

T?
 
Joined
Jan 28, 2008
Messages
2
Reaction score
0
I am a little further in my investigation. I removed the SelectedIndexChanged from the radiobuttonList/DropdownList and then the Textbox.textChanged is executed. But I would it to be executed as well. First textbox.textChanged and then radiobuttonList.SelectedIndexChanged was what I wanted.
 
Joined
Jun 9, 2010
Messages
1
Reaction score
0
I have the same problem

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
Code:
<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
Code:
 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 error of developing new functions.
ps: sorry for my english.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top