Search code examples
c#.netwinformscheckboxwebbrowser-control

Uncheck a checkbox in webpage through WebBrowser control


Is there a way to uncheck/check a checkbox within a webpage that is loaded within a webbrowser control? Thank you.

Update: (This is what I originally tried with no luck)

HtmlDocument rememberme = this.webBrowser1.Document;
rememberme.GetElementById("remBox").SetAttribute("checked", "false");

Solution

  • You can use:

    webBrowser.Document.InvokeScript

    see:

    InvokeScript

    This way you can call JS function that will do what you want to the page.

    Another way is to use mshtml API, like this: ( ( HTMLInputElement )this.webBrowser1.Document.GetElementById( "test" ).DomElement ).@checked = false;