Working with frames in webbrowser Control

user989888 picture user989888 · Oct 18, 2011 · Viewed 10.5k times · Source

I am using <webbrowser>.Document.Window.Frames to get frames. My <WebBrowser> having 2 frames.My only problem is ,I seem one at index 0, but not 1.

Any help?

HtmlWindow wf = wb.Document.Window.Frames[1]; 
string s = wf.Document.Body.OuterHtml; 

and view source

    <frameset rows="0,*" border="0" frameborder="0" framespacing="0"> 
    <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"> </frameset>

Answer

Ashkan Mobayen Khiabani picture Ashkan Mobayen Khiabani · Dec 3, 2011

Try getting frames using their name instead of index:

wb.Document.Window.Frames["entrustTruePassAppletFrame"];

Actually I think using index is not good at all, because if at a later time you add/remove a single frame it ruins all your work as the indexes changes.