I have a rather complex little problem facing me. The company I work for implements a CRM application that is purely a web application. We have clients that use a Card Scanning Solutions license scanner to gather information about the customer. I need to make the following happen.
User logs into an ASP or ASP.NET 2.0 site.(we have two versions of our application)
User clicks a button on an IE toolbar and a dialog is displayed that prompts them to insert the license into a scanner.
Clicking through this dialog makes a call to the Card Scanning Solutions license scanning SDK which is registered as a COM object on the user's system.
The scanner returns information read from the license to IE and IE closes the prompt dialog and then opens a second dialog to display the license image and what the SDK was able to read from the license image. All of the information on this dialog is displayed in text boxes and drop down lists along with additional information that is added through additional controls on the dialog. The additional controls use ASP.NET 2.0 Web Services to get data to place into them in the case where those extra controls are drop down lists.
Once the data is on the dialog properly, the user selects a submit button and the information is written to a preconfigured location on their hard drive. The dialog should then be able to build a Url with that information on the query string and submit it to the hosting browser for redirect.
Two additional functions need to be present.
A configuration page of some sort that allows the user to set a CSV or XML data output format and declare a drive location for the file to be saved to.
A scanner calibration button that implements a dialog instructing the user to insert the scanner calibration page into the device before clicking a start button on the dialog to actually do the calibration.
I've implemented this as a Windows Forms application that embeds a WebBrowser object and everything works perfectly fine. I even have an install project that installs the drivers for the scanner, COM objects for the SDK and the Windows Forms application in one step. The problem with that approach is that any Url in the web pages of the application that uses target="_blank" or a javascript based popup does not work. The Url brings up the new window in IE and immediately loses all session state information from the WebBrowser control. I've searched for a solution to passing the ASP.NET and ASP session info to the spawned IE window and have come up empty handed. IIS thinks that the web request from IE and the one from MyWindowsFormsWebBrowser are two distinct browsers and therefore require two different sessions.
This led me down the path of IE7 AddOns which I'm hoping I can embed a series of dialogs that can read from a local device, write to the users hard drive and call a web service or two before redirecting the browser to the appropriate page after the button is clicked. Advice on how to alter my approach to solving this problem is greatly appreciated.
Derek Licciardi
ps If an IE AddOn is the key to solving my problem then are there any tutorials on creating an AddOn in .Net 2.0. What about deploying an IE AddOn My users know nothing about computers and need something as simple to install from the web as say the Macromedia Flash player. In other words the install process can't mention registering a COM object or placing an assembly into the GAC...

using a scanner with Ie.
Navya Jeevan
Barry333
黄达
For the problem you are facing in your WinForm application, you would need to handle the NewWindow2 event of the webbrowser control, so that IE is not used by default for handling frame targets. This page has some good information regarding this - http://support.microsoft.com/kb/184876. Another suggestion would be to use ActiveX control to implement the required functionality and users would be able to access the application through IE itself. Please check out http://msdn.microsoft.com/library/default.asp url=/workshop/components/activex/activex_node_entry.asp for more information regarding ActiveX. I would especially recommend giving the security design of the control a thorough review since it would interact with the scanner hardware on the user machine (one of them being exposing the functionality only to the set of required domains from which the application would be accessed).
regards
Sharath
eko007
Unfortunately the knowledge base article applies to MFC and an old version of Visual Basic. The WebBrowser control in .Net 2.0 does not have a NewWindow2 method or a RegisterAsBrowser property. I wish it did because the gist of what I was seeing in that article would allow me to accomplish what I need to using my existing application. I'm trying to work with the .NEt 2.0 WebBrowser control to see if I can override Navigate and force all navigation into the existing window. While this is somewhat of a hack, it will work for the context that we're needing it to work.
Joao Pinto
I've done some research into the matter and I was able to use the NewWindow event of the .Net 2.0 WebBrowser control to stop popups from happening.
All you have to do is set e.Cancel = true and then browser.Navigate(browser.StatusText, false). You can also pass the frame name to navigate to and force the popup to render in the current window. That said, everything works until you navigate to a PDF file which causes a new window when the Adobe plugin loads. The PDF loads in the new window fine and even has data from a session variable in the PDF but the browser control left behind in the original window is left in an unknown state. I'm trying to figure the work around to this but didn't have too much time to work on it yesterday. The WebBrowser control is pretty close to giving me what I need and I am hoping that I can do this without having to resort to a BHO or some other rewrite of my existing approach.
Derek Licciardi
Tvienti
The answer for our project was to create a Windows Forms application with a WebBrowser control in it. Implement a handler for the NewWindow event that set e.Cancel = true. Then I had to check the WebBrowser.StatusText for something indicating that it was a pdf/fdf file being requested. If this is false then I am navigating to a web page and I can simply call WebBrowser.Navigate(url, false) or WebBrowser.Navigate(url, "frame name"). When a pdf file is being requested, I create another WebBrowser object in the NewWindow event and tell that object to navigate to the pdf file leaving the control on my form stuck on the same page.
This worked for us in our situation though I am fairly certain that in a much less controlled browsing environment there will be other issues to contend with. For instance, we had to add "back" links to some of the popup forms and a bit of javascript to hide or display them based on if the window displaying the form was actually in a popup or it was redirected to the main frame of our application. Since this browser is intended for use with a single web application and the web application is aware of how this browser is changing the application the solution works for us.
Derek Licciardi
crussting
This is not on Vista. At best I'll be able to make Windows XP Svc Pk 2 a requirement. We have clients that still use Windows 2000 and have little to no plans on moving to Vista come the first quarter of next year. Any solution I arrive at has to work with Windows XP. I am willing to tell clients that a solution does not work on Windows 2000. I am also willing to force them to upgrade to IE7 as this has little impact to most of our clients.
Your thoughts are appreciated.
Derek Licciardi