How can I get the state of a HTML CheckBox in a WebBrowser control?
I have the following variable in my class:
private WebBrowser quickStartGuideContentWebBrowser = new WebBrowser();
I also have the following constant in my class:
private const string doNotShowAgainCheckBoxElementId = "do-not-show-again-checkbox";
I also have the following function in my class;
private HtmlElement GetDoNotShowAgainCheckBox()
{
HtmlDocument document = this.quickStartGuideContentWebBrowser.Document;
if (document == null)
{
Debug.WriteLine("GetDoNotShowAgainCheckBox error: (document == null).");
return null;
}
return document.GetElementById(doNotShowAgainCheckBoxElementId);
}
I am trying to implement a IsDoNotShowAgainCheckBoxChecked method as follows:
private bool IsDoNotShowAgainCheckBoxChecked()
{
HtmlElement checkboxElement = GetDoNotShowAgainCheckBox();
if (checkboxElement == null)
{
Debug.WriteLine("IsDoNotShowAgainCheckBoxChecked error: (checkboxElement == null).");
return false;
}
// What magical incantation do I put here
// to retrieve the checked state of checkboxElement as a bool?
return false;
}