Click here to Skip to main content
15,881,794 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Please see the following code.

C#
private void Form1_Load(object sender, EventArgs e)
       {

           geckoWebBrowser1.Navigate("http://localhost:62343/ReportPage.html);

       }

private void Form1_Shown(object sender, EventArgs e)
       {
           var item1 = geckoWebBrowser1.Document.GetElementById("DynamicGrid");

           htmlelem = item1.InnerHtml;
       }


The problem is that when I run my project I get item1 as null in Form1_Shown.

But When I put this code under a button event like

C#
private void buttonGetDom_Click(object sender, EventArgs e)
        {
             var item1 = geckoWebBrowser1.Document.GetElementById("DynamicGrid");

            htmlelem = item1.InnerHtml;

        }


Then I get the innerhtml. How can I Get innerhtml of this Element in Form_Shown ?

Please keep in mind that I need to access this DOM only from from Form1_Shown and I am using GeckoWebBrowser.

Can anyone help me please ?
Posted
Updated 11-Dec-14 2:29am
v2

1 solution

You won't be able to access the document until the control has finished loading the page.

Assuming you're using the control from the GeckoFX[^] library, you need to wait for the DocumentCompleted event to be raised before you can access the document.
 
Share this answer
 

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