[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 589
  • Last Modified:

webbrowsercontrol working with Frams in c#.net

How can I retrieve frame controls by using webbrowsercontrol?

I am using webbrowserControl in c#.net to automation submition of a form in java based website.
The page which I am trying to submit is having  frames .
The controls -Username and password controls are in that frames.

Its urgent any help will be useful for me.
<webbrowserControl>.Document.Window.Frames to get frames.
But no use i need to get the controls and enter username and password.

Attached is screen and source code for the webpage.

Please help me.
<!-- Entrust TruePass 8.0 -->

        <title>Authenticate Entrust Roaming Security Store User</title>

        <!-- The following 5 <script></script> - tags are needed to load the JavaScript
        functions and configuration into the page. They have to be in the final page
        exactly as they are here. Of course the commentaries can be removed. -->

        <!-- The empty <script></script> - tag is needed because of a bug in Netscape
        browsers. Sometimes Netscape browsers don't execute the code in the first
        <script></script> tag but they will always execute the code contained in all
        the following <script></script> tags on the same webpage. -->
        <script language="JavaScript">
        <!-- This <script>/<script> - tag loads the configuration file into this page. -->
        <script language="JavaScript" src="javascript/EntrustTruePassClientConfig.js">
        <!-- This <script></script> - tag loads the JavaScript functions into this page.
        You must not call any function contained in this file directly. They are all called
        through the API -->
        <script language="JavaScript" src="javascript/EntrustTruePassClientPrivate.js">
        <!-- This <script></script> - tag loads the API into this page.
        This API contains every function that can be called from the webpages. -->
        <script language="JavaScript" src="javascript/EntrustTruePassClientAPI.js">
        <!-- This <script></script> - tag calls the function that initializes the API. -->
        <script language="JavaScript">

    <!-- The frameset defines two frames, where one is an invisible frame (size 0) that
    contains the applet and the other frame contains the GUI. -->
    <frameset rows="0,*" border="0" frameborder="0" framespacing="0">
        <!-- It's mandatory that the Applet page in this frame contains the applet,
        without any additional frame in it, because the Applet Page creates a link
        to this page.
        The name of this frame must be the same as defined in the Configuration as
        appletFrameName. -->
        <frame name="entrustTruePassAppletFrame" src="EntrustTruePassApplet.html" marginwidth="0" marginheight="0" scrolling="no" noresize>
        <!-- It is mandatory for the frame where the user interaction happens to have
        the name defined in the Configuration as appletHtmlGuiTarget-->
        <frame name="entrustTruePassGuiFrame" src="AuthenticateUserInputRoamingEPF.html">

Open in new window

  • 2
1 Solution
Frames are a tricky thing to use in programming for many reason. They have security built in them and you CANNOT access ANY object in a frame from the page including the frame.

Imagine this, you add "https;//gmail.com/" to your page via a frame. Let's assume you are a malicious person and that Frames allowed what you want them to do. Someone clicks a link to your site and thinks they are logging into GMail. Your code retrieves the person's username/password from the frame, stores them to your databse, and sends them to Google as if nothing happened. TERRIBLE security hole this way.

If you need access to those controls, you can't do it in a frame.
NettodotnetAuthor Commented:
After researching one day i find this solution.Just in case some one need :).

--this will give you html
string str =<WebControl>.Document.Window.Frames["<FrameName>"].Document.Body.InnerHtml;

--Pick the controls name and use in below code
HtmlDocument doc = wb.Document.Window.Frames["<FrameName>"].Document;
                doc.GetElementById("<username>").InnerText = "abc";
                doc.GetElementById("<password>").InnerText = "cba";
NettodotnetAuthor Commented:
find out soluiton by myself

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now