0
votes

there is a webform with a checkbox

input class="checkbox" type="checkbox" name="subscribe" value="1" checked="checked"

using the webbrowser control and WebBrowser1.Document.GetElementsByTagName("input");

how can i uncheck the damm checkbox

My try

HtmlElementCollection elements4 = WebBrowser1.Document.GetElementsByTagName("input");

                    foreach (HtmlElement element4 in elements4)
                    {
                        if (element4.Name == "subscribe")
                        {


                            element4.SetAttribute("subscribe", "false");
                           element4.InvokeMember("unchecked");

                          //  element4.checked = false;// doesn't even exist this line


                        }
1

1 Answers

0
votes

Use the SetAttribute to set the checked attribute. In this case:

element4.SetAttribute("checked", "false");

SetAttribute accepts two arguments, the name of the attribute you want to set, and a value. You can look at the MDC for a list of all of the other properties you can set: https://developer.mozilla.org/en/DOM/HTMLInputElement