Tips and Tricks in a world of Mix

Archive for 14/12/2010

Upgrade to MVC2


Well , the problem I’ve met was moving to a new computer.

All of a sudden my development project , that has been upgraded from MVC1 to MVC2 months ago , suddenly refused to work . My new computer never had the installation of MVC1. (You can check if the GAC is familiar with MVC1)


I’ve got message saying that I’ve got MVC1 references in my project :


The stack trace was :


So I started looking for MVC1. Well after a little wild I found this :


Through Red Gate’s .Net Reflector I opened a suspicious  .dll in this mortal sin , and found out that the Mvc it references is MVC1. Also in their site it said :

Important: xVal is recommended for use only with ASP.NET MVC 1.0

If you’re using ASP.NET MVC 2.0 or later, the framework has built-in support for generating client-side validation logic directly from model metadata. You can still use xVal if you wish, but it won’t be actively developed or supported.

My solution was



Welch Allyn IT3800 code interceptor


Look at the scanner jack.

If it looks like this:

, then it’s a keyboard wedge scanner. It acts like a keyboard: just types your barcode into an edit field.

If it looks like this:

, it’s a serial port scanner.

You need to create an instance of System.IO.Ports.SerialPort and use it to communicate with the scanner.

If it looks like this:

, it’s a USB scanner. From programmer’s point of view, it can be either a keyboard wedge or a serial port scanner.


Ours was wedge scanner. If we want to intercept the barcode input , for instance for validation or some logic decision where to show the input , then you should catch the Ctrl+b event , initialize a flag saying you’re now reading the barcode . On each KeyPress you’ll hit , if it’s not “Enter” (the end of Barcode input) and the flag of  (Ctrl+b)  (Start Barcode Read) is true , add each time add the value to some parameter. When the “Enter” comes you have all the bar code data in the parameter. :


  1: var barcodeWorking = false;
  2: var barcode = "";
  4: //This function fired when ctrl+b insert : begin reading with barcode
  5: function FireEventB_KeyAndONE_Key()//Override the function of KeboardUse.js
  6:       {
  7:           barcodeWorking = true;
  8:           window.focus();//כדי שהברקוד לא יכתב לרכיב טקסט בדף
  9:       }
 11: function KeyPress(theKey)
 12:       {
 13:            var key=theKey.keyCode || theKey.which;
 14:            if(barcodeWorking)
 15:            {
 16:                if(key == ENTER_KEY)//'Enter' pressed : end of the barcode
 17:                {
 18:                     alert(barcode); )//לעשות מה שצריך עם הברקוד
 19:                     barcode = "";
 20:                     barcodeWorking = false;
 21:                }
 22:            else
 23:            {
 24:                 barcode += String.fromCharCode(key);
 25:            } 
 26:         }
 27:       }


Don’t forget to connect the KeyPress to Body tag.

   1:  <body language="javascript" onload="windows_onload();" oncontextmenu='return false' onkeypress="KeyPress(event)">


The idea has been generated by me.

The source code (implementation) has been written by Sharon Said.

Tag Cloud

%d bloggers like this: