Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was writing a small program in Visual C# 2010 to ultimately be loaded on a handheld scanner with WinCE 5. Works great in 2010.

Come to find out, I needed to use the 2005 version. So I copied my code over to 2005, and now the TextChanged event doesn't trigger. I have tried it in a regular Windows App in 2005 as well, with the same results. The data goes into the textbox just fine, but changing the text doesn't trigger the event.

I have a textBox with this code attached. I test it in Windows by just Ctrl-V the data into it and it would trigger fine. In 2010, works great, not in 2005. On the handheld, the scanner will put info in this box.

C#
private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //only get scan if txtbox isnt empty
            if (textBox1.Text.Length > 0)
            {
                scanCode = ReadCode();
                //if scanCode == null that means it was a bad scan
                if (scanCode == null)
                {
                    button1.Text = "Wrong Barcode - Try Again";
                    button1.BackColor = System.Drawing.Color.Red;

                    //Log that someone scanned the wrong barcode
                    log.WriteLine(DateTime.Now);
                    log.WriteLine("Invalid Barcode scanned");
                    log.WriteLine("Code = " + scanCode);
                    log.WriteLine();
                    log.Flush();
                }
                else //else it was a good scan
                {
                    ProcessScan();
                }

            }
        }


Anyone know of any differences between the versions that would keep this from triggering? Any help is greatly appreciated.
Posted

Hello

try to chceck whether textbox1 has property AutoPostBack=true and whether AutoEventWireUp in Page directive is true. If it is not true, you must bind method on event manualy.

http://msdn.microsoft.com/en-us/library/system.web.configuration.pagessection.autoeventwireup.aspx[^]

http://forums.asp.net/p/932513/1096656.aspx[^]

Regards
Robert
 
Share this answer
 
Most likely reason is that the event is not hooked up. Search your project for "textBox1_TextChanged". You should find 2 instances, the definition and the event hookup in the auto-generated designer file.
 
Share this answer
 
v2
If you double click the button in VS2005 in the design view, you would most likely generate the actual event handler for the button in VS2005 app which will look like textbox1_TextChanged_1 . Coz when you pasted it from VS2010, it was created and hooked up with the button1 in VS2010 app, so to re-wire it to VS 2005 try re-generating the event handler and then paste the body over from VS2010.

Hope this helps.

Cheers.
 
Share this answer
 

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



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