Click here to Skip to main content
12,888,931 members (51,308 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# Automation
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'
scrolling='no' frameborder='0' id='xyzlogin' name='xyzlogin'

Within that frame I need to access these three elements:

<input type="text" name="Email" value="" class="xyz le val" id="Email"
<input type="password" name="Passwd" class="xyz le val" id="Passwd"
<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 10-Oct-11 9:54am
Updated 10-Oct-11 10:13am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can try using the below code:

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");
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.


hope this solves your problem.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2017
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