Looking for a solution to my issue. We are building a web browser control into a product for a client, they need to be able to detect when there is a File Upload box on a website, then instead of it launching the Windows 7 File Browser window, it needs to open their own custom designed one
Is there a browser event that allows us to capture that?
You can hook up your own download manager that is effective only in your webbrowser control host process by implementing IServiceProvider in the control site and implement QueryService to return an IDownloadManager object when asked by the webbrowser control
In Windows Form's Webbrowser class, a control site is created for you by default, but you can override the control site by create your own WebBrowserSiteBase class and override the WebBrowser.CreateWebBrowserSiteBase Method. There is no such extensibility if you use the webbrowser control from WPF, Silverlight or Windows Phone.
I suggest you write the download manager in C++ due to the amount of interop required if you code in C#. There's an example for a C# webbrowser control using a native download manager here.
You can catch the FileDownload
event, and handle it yourself.
See http://msdn.microsoft.com/en-us/library/bb268220(v=vs.85).aspx
After showing your custom file dialog, send the data back to the webbrowser control, and submit the form.
Another option is to inject javascript into the control. Inject a code that replaces the call from the upload button, and show a form of your own instead.
So you want to modify the value of <input type=file ....
You cannot do that with webbrowser control because it accesses DOM like javascript, vbscript vs. And if DOM allowed accessing and changing the uploaded file bad guys could easily steal your local files (using javascript) when you visit their pages.
Furthermore you can't even see the value of FileUpload because of that security issue.
If you want to select a file programmatically that is possible with a combination of SendKeys