Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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.
 
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 28-Oct-11 11:44am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 584
1 Maciej Los 275
2 DamithSL 233
3 Sergey Alexandrovich Kryukov 209
4 BillWoodruff 200
0 OriginalGriff 6,803
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,421
3 Manas Bhardwaj 4,841
4 Maciej Los 4,330


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 28 Oct 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100