Search for RadioButton

Eduardo Lorenzo

Regular
Joined
Jun 27, 2006
Messages
87
Hi everyone,
This has got me stumped.
What I am trying to do is search for a "Clicked" HtmlInputRadioButton inside a tabcontrol. I have no idea what the ID is, or which tab the radioButton will be in.
So the flow will be to go through all the controls in the each tab, check if it is an HtmlInputRadioButton, check if it is "checked" and return the Value.

This is what I have at the moment and it can find the radio button(when I debug it) but doesnt return the value because it continues on to the next controls.

Visual Basic:
   public static string FindControlRecursively(Control controlName)
    {
        foreach (Control Ctl in controlName.Controls)
        {
            if (Ctl is HtmlInputRadioButton)
            {
                HtmlInputRadioButton testRB = ((HtmlInputRadioButton)(Ctl));
                if (testRB.Checked)
                {
                    return testRB.Value;
                }               
            }
            return FindControlRecursively(Ctl);
        }       
    }

It doesn't seem to want to exit this function until all controls have been read.
 
Back
Top