Hi all,

I have a question about moving through the elements in a web browser via C#. I currently am trying to get a checkbox to become unchecked using the HtmlElementsCollection...
I have so far been able to implement putting text into a message box that is on a webpage, but I cannot figure out the right syntax for unchecking a checkbox. This is what I've tried so far (the first one is the message box, it works. Second one is the checkbox...no luck):

HtmlElement addMsg = this.webBrowser1.Document.All[gc_inviteFriendMsgBox];
                addMsg.SetAttribute("value", "Heya, I totally worked!");

                HtmlElement actStream = this.webBrowser1.Document.All[gc_inviteActivityBox];
                actStream.SetAttribute("checked", "unchecked");

Instead of "unchecked" I have tried 0 and false...any help here? =\ I have huge troubles with MSHTML when I tried to implement that...kept saying I need a reference to an object with the new keyword but every time I tried that it would say I can't...

Thanks

Recommended Answers

All 3 Replies

Since the SetAttribute method sets the value of the name, you wouldn't want the value for "checked" to be "unchecked" because it expects a state flag value for a checkbox's state. Have you tried: SetAttribute("checked", "false") ?

You have to clear the checked attribute, i.e. SetAttribute("checked", "")

Welcome tongriff.

Please do not resurrect threads that are years old. By doing so you run the risk of confusing current posters and/or reopening old wounds.

Thread Closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.