Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi All,
I am trying to set the select image path to a file upload control inside a browser control.
I am using this code:
 
HtmlElement ImgTxt = webBrowser1.Document.GetElementById("ImageName");
 
ImgTxt.Focus();
 
SendKeys.SendWait(imgPath);
 
but nothing is chnaging can anyone help please?
Posted 19-Jul-12 14:19pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You're using SendKeys, that means you're using the web browser control in a windows app ? SendKeys is retarded and hacky, you should never use or trust it. It's a VB6 hack that should have died with it.
 
The file upload control has special protection to stop hackers using it, you can't set it's value in code, and it could well be blocking what you're trying to do here, too.
  Permalink  
Comments
Mohammad Al Hoss at 19-Jul-12 21:17pm
   
What should I replace it with?
Christian Graus at 19-Jul-12 21:21pm
   
You should expect to interact with elements on your form by getting a reference to them. In this instance, as I said, I don't think it's possible.

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

  Print Answers RSS
0 OriginalGriff 693
1 George Jonsson 370
2 BillWoodruff 337
3 Sergey Alexandrovich Kryukov 259
4 Garth J Lancaster 240
0 Sergey Alexandrovich Kryukov 10,764
1 Maciej Los 5,474
2 OriginalGriff 5,472
3 CPallini 3,819
4 BillWoodruff 3,594


Advertise | Privacy | Mobile
Web03 | 2.8.141030.1 | Last Updated 19 Jul 2012
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