I need to select a radio button, but when I use Click(), it doesn't get checked. My code is:
Dim p as new HtmlPage("BloodPressureDemographicV100P01.aspx")
p.Elements.Find("SmokingStatus_0").Click()
The element exists on the page, but it never gets selected. I also tried HtmlElement.DispatchEvent(New HtmlMouseEvent("click")), but it doesn't work, either.
After some hair pulling, I realized that an ASP.NET RadioButtonList renders as a span with a radio button element and a label element inside it. The solution, using the code above, is to do this:
jmarmet
Member
7 Points
8 Posts
RadioButton not being selected with Click()
Dec 29, 2010 03:18 PM|LINK
I need to select a radio button, but when I use Click(), it doesn't get checked. My code is:
Dim p as new HtmlPage("BloodPressureDemographicV100P01.aspx")
p.Elements.Find("SmokingStatus_0").Click()
The element exists on the page, but it never gets selected. I also tried HtmlElement.DispatchEvent(New HtmlMouseEvent("click")), but it doesn't work, either.
Can anyone help?
jmarmet
Member
7 Points
8 Posts
Re: RadioButton not being selected with Click()
Dec 29, 2010 08:02 PM|LINK
After some hair pulling, I realized that an ASP.NET RadioButtonList renders as a span with a radio button element and a label element inside it. The solution, using the code above, is to do this:
p.Elements.Find("SmokingStatus_0").ChildElements(0).Click()
farmas
Participant
1164 Points
259 Posts
Microsoft
Re: RadioButton not being selected with Click()
Jan 07, 2011 09:15 PM|LINK
Sorry for the late reply... Glad you got it working. :)
Cheers!