Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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.
 
Share this answer
 
Comments
Mohammad Al Hoss 19-Jul-12 21:17pm    
What should I replace it with?
Christian Graus 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900