c# - How can I get if checkbox is checked -
I am trying to get the checked attribute of the checkbox I am trying to use GeckoHtmlElement
's GetAttribute ()
function but it always returns zero value for the checked
attribute .
I try this:
Gecko .GeckoElementCollection z = Browser.Document.GetElementsByName ("product box []"); Forchha (in GechoGeekoNADZ) {if (o. nodotype == nodetype.alment) {GECOHotelElementAds = (GokohatlAlment) o; String aa = asd.GetAttribute ("check"); If (aa! = Null & amp; aa == "true") liaa.Add (o); }}
Checkbox HTML:
& lt; Input name = "productbox []" value = "10914" class = "noborder" type = "checkbox" & gt;
I try it but still does not work. This gives a null Gačko node:
string aa = asd.Attributes ["checked"]; Update:
I have completed my work, but my method is uggly, dirty and less usable. DomMouseUp
Event in the browser:
GeckoElement Active = (GeckoElement) Browser. Document. ActiveElement; If (active properties ["name"]. TextContent == "product box []") {if (getHtmlelement (active) parent.getAttribute ("style") == faucet || getHtmlelement (active). GetAttribute ( "Style") == "") {getHtmlelement (active) .SetAttribute ("style", "mitchcheck"); Liaaa.Add (active); } And {getHtmlelement (active) .net-attribute ("style", ""); Liaaa.Remove (active); }}
This is working for now because all checkboxes are not checked when pages are loaded by default. But better ways can be a great help.
Thank you
Casting in a GeckoInputElement will give you access to the checked property:
if (O.NodeType == is the nodtip. Element & amp; gkpointimension element) {GeckoInputElement asd = (GeckoInputElement) o; If (asd.Checked) ....}
Comments
Post a Comment