How to uncheck a checkbox in vb.net webbrowser?

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 13038 Views - Last Post: 20 November 2012 - 07:48 AM Rate Topic: -----

#16 tyscof  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 28-March 11

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 15 April 2011 - 09:11 AM

View PostLaughingBelly, on 15 April 2011 - 08:31 AM, said:

So go ahead and post some code around the problem area. Without it we are all assuming a lot of things.

Lol if you don't understand the question you can not help. If you knew the answer you wouldn't need any more clarification as i have given plenty. I don't mean to be rude and i am sorry if you take it that way i dont mean to be.
Was This Post Helpful? 0
  • +
  • -

#17 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,507
  • Joined: 16-March 11

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 15 April 2011 - 09:28 AM

View Posttyscof, on 15 April 2011 - 09:11 AM, said:

View PostLaughingBelly, on 15 April 2011 - 08:31 AM, said:

So go ahead and post some code around the problem area. Without it we are all assuming a lot of things.

Lol if you don't understand the question you can not help. If you knew the answer you wouldn't need any more clarification as i have given plenty. I don't mean to be rude and i am sorry if you take it that way i dont mean to be.


Post some code. Other than people giving you hints as to what method you should use, nobody is here to give you the answer, you're figuring that out yourself.
Was This Post Helpful? 0
  • +
  • -

#18 LaughingBelly  Icon User is offline

  • D.I.C Head

Reputation: 47
  • View blog
  • Posts: 103
  • Joined: 11-April 11

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 15 April 2011 - 11:25 AM

Normally I would agree that I am not understanding your question right. But, looking at the number of responses, is it not clear that there is not enough background to your question? We have One line of code to work with. We don't even know what data type el is - we only have your word to go by. You seriously expect that everyone knows an answer to a question that is ambiguous?

After typing that block, I made a small test program just to see if I am really not getting it. I did get a checkbox in a webbrowser control working just fine.

After trying this - I am definitely sure that I did not understand your question. Sorry for all the responses that lead you no where. I hope somebody else understands your question.
Was This Post Helpful? 0
  • +
  • -

#19 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 15 April 2011 - 12:00 PM

Well, having had a good look around other forums, I'd say that your best bet is executing a piece of javscript on the webbrowser's document to uncheck the checkbox.
Was This Post Helpful? 0
  • +
  • -

#20 LaughingBelly  Icon User is offline

  • D.I.C Head

Reputation: 47
  • View blog
  • Posts: 103
  • Joined: 11-April 11

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 15 April 2011 - 12:17 PM

New update! I have also solved the problem your way. Now I really wish you gave us the code surrounding the snippet instead of wasting all of our time. Just searching for htmlelement that your el corresponds to on msdn gave enough information to get to a solution that you were looking for.
        Dim htdoc As HtmlDocument
        Dim el As HtmlElement
        htdoc = WebBrowser1.Document
        el = htdoc.GetElementsByTagName("input").Item(0)
        el.SetAttribute("checked", "")



Next time, please do post more code around your question. One line is not enough to do any research on without understanding the context. For a minute I almost thought you did not really want an answer from the way your responded to my request for more code.

Edit: It is also possible to check the current state of the checkbox. From your comments I thought it would be a difficult thing to achieve.

Quote

If you knew the answer you wouldn't need any more clarification as i have given plenty.

Please understand that you are not able to make that assessment as you don't know what we understood from your question.

This post has been edited by LaughingBelly: 15 April 2011 - 12:29 PM

Was This Post Helpful? 0
  • +
  • -

#21 tyscof  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 28-March 11

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 15 April 2011 - 12:46 PM

        Dim htdoc As HtmlDocument
        Dim el As HtmlElement
        htdoc = WebBrowser1.Document
        el = htdoc.GetElementsByTagName("input").Item(0)
        el.SetAttribute("checked", "")


I am pretty sure I tried this i hope not tho. I will test it monday if it does work than thank you. Yes el as i said was an html element on the page x.x I guess i could have been more clear.. thanks ill try it. hope it works. Thanks for the negative rep btw. -_-"

This post has been edited by tyscof: 15 April 2011 - 12:48 PM

Was This Post Helpful? 0
  • +
  • -

#22 zizokeriaky  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-October 12

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 12 October 2012 - 01:12 PM

LOok bro this code worked with me


Dim a As HtmlElementCollection = WebBrowser1.document.All
        For Each el As HtmlElement In a
If el.GetAttribute("name") = "persistent" Then
                If el.GetAttribute("checked") Then
                    el.InvokeMember("click")
end if 
end if 




note i used this for facebook login you can use your own element ids :D
Was This Post Helpful? 0
  • +
  • -

#23 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 12 October 2012 - 01:57 PM

Did you happen to look at the date the last entry to this topic was made. I'm sure the OP has either resolved this or given up by now.
Was This Post Helpful? 0
  • +
  • -

#24 mbv401920150  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-December 11

Re: How to uncheck a checkbox in vb.net webbrowser?

Posted 20 November 2012 - 07:48 AM

View PostCharlieMay, on 14 April 2011 - 04:13 PM, said:

Not sure but SetAttribute's parameters are AttributeName and Value and since you used
el.SetAttribute("checked", "checked") and that worked, did you try
el.SetAttribute("checked", "unchecked")

Since you're talking about the same attributename.

Of course, I have no idea if unchecked is a valid value it's just a guess.

Maybe some code that sets up your document for the browser would help.


Thanks!, works for me!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2