开发者

Manually selecting web page radio button

开发者 https://www.devze.com 2023-03-06 15:59 出处:网络
i want to programatically select a radio button in code. The radio button lives on an internal webpage.

i want to programatically select a radio button in code. The radio button lives on an internal webpage.

I am trying so far like this,

HtmlElement rButton = b.Document.GetElementById("nameOfButton) 

whi开发者_StackOverflow社区ch i assume gets me a handle on the radio button, but i cant find a .selected = true or something similar. I need to do this because on the page, when this button is selected more values appear on the page which i then need to fill out.

edit: i think i have managed to do this using

rButton.invokemMemeber("click") - however i think i am still going down a cul de sac with this one.

i would like to add, i think that the page is using postback. if i click the radio button, a set of new options on the page appears, its one of these dynamically created text boxes i need a handle on. is this going to be impossible to get?


You could do,

 var rButton = b.Document.GetElementById("nameOfButton"); 
    if(rButton != null)
         rButton.checked=true;

Hope this help.


This is what worked for me:

if (doc.GetElementById("nameOfButton") != null)
            doc.GetElementById("nameOfButton").SetAttribute("checked", "true");

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消