2

I'm trying to select an option in the web page with axwebBrowser control.

I know how to select a value, here is my code: mshtml.IHTMLElement ddlid1b = doc.getElementById("id56"); ddlid1b.children[3].SetAttribute("selected", "selected");

After that I have Fired the Change Event like below

var el3 = (ddlid1b as IHTMLElement3); el3.FireEvent("onchange");

But there is one problem,when the website automatically refreshes when the value is changed, so when I use my code, the value in the select box changes, but website doesn't refresh.

Is it Possible to post back the page like in .aspx pages .

How do I make this work?

Thank you in advance

purna.n
  • 287
  • 1
  • 3
  • 11

1 Answers1

1

Finally I have solved this problem using the Time Control.

After Completion of the Drop Down Selection event we need to start the Timer like

mshtml.IHTMLElement ddlid1b = doc.getElementById("id56"); ddlid1b.children[3].SetAttribute("selected", "selected"); var el3 = (ddlid1b as IHTMLElement3); el3.FireEvent("onchange");

Timer.Start();

In the Tick event we need to download And do the Operations

  private void timer1_Tick(object sender, EventArgs e)
    {           
       try
        {

                timer1.Stop();
                mshtml.HTMLDocument doc1 = (mshtml.HTMLDocument)axWebBrowserClaims.Document;
                IHTMLElementCollection col = doc1.forms;

                mshtml.HTMLDocument doc3 = (mshtml.HTMLDocument)axWebBrowserClaims.Document;
                string html2 = doc3.body.innerHTML;

                mshtml.IHTMLElement ddlStates = doc3.getElementById("ddlStates");
                ddlStates.children[1].SetAttribute("selected", "selected");


                mshtml.IHTMLElement txtDistrict = doc3.getElementById("txtDistrict");
                txtDistrict.innerText = "Khammam";

                mshtml.IHTMLElement btnSubmit = doc3.getElementById("btnSubmit");
                btnSubmit.click();
            }

        }
        catch (Exception ex)
        {
        }
    }

thanks...

purna.n
  • 287
  • 1
  • 3
  • 11