Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the Webbrowser control(IE object) in VS 2008 C# Express to automate the
navigation of pages on a partner's web site. The first page contains
an <IFRAME> element:

<iframe style='width:40; height:40'; align='center' marginwidth='0'
marginheight='0'
scrolling='no' frameborder='0' id='xyzlogin' name='xyzlogin'
src='https://www.xyzcorp.com/accounts/ServiceLogin'>
</iframe>

Within that frame I need to access these three elements:

<input type="text" name="Email" value="" class="xyz le val" id="Email"
size="18">
<input type="password" name="Passwd" class="xyz le val" id="Passwd"
size="18">
<input type="submit" name="null" value="Sign in" class="xyz le button"

so I to automate programmatically this login: 1)enter the user ID and password, and 2)click
the 'Sign in' button.


can someone provide me code sample how to resolve this.
Posted
Updated 10-Oct-11 10:13am
v5

You can try using the below code:

C#
ContentPlaceHolder holder = (ContentPlaceHolder)this.CurrentMaster.FindControl("xyzlogin");

HtmlControl control1 = (HtmlControl)holder.FindControl("Email");
HtmlControl control2 = (HtmlControl)holder.FindControl("Passwd");
HtmlControl control3 = (HtmlControl)holder.FindControl("Signin");
 
Share this answer
 
the document object of the webbrowser control has a property called window object, this would give reference to the iframe controls

if your webbrowser control name is webBrCtrl then the below line should give you the collections of iFrames in the HTML document that is loaded in the webbrowser control.



webBrCtrl.Document.Window.Frames


hope this solves your problem.
 
Share this answer
 
v2

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