The Mask
The Mask

Reputation: 17447

jscript document.getElementsByName in C#

which is similar in c# ?

var e = document.getElementsByName("test")[0];
var HTML = e.innerHTML; 

Upvotes: 0

Views: 340

Answers (2)

thinkdevcode
thinkdevcode

Reputation: 931

Recursive FindControl method:

    private Control RecursiveControlFind(Control parent, string controlID)
    {
        Control child = parent.FindControl(controlID);
        if (child == null)
        {
            if (parent.Controls.Count > 0)
            {
                foreach (Control nestedControl in parent.Controls)
                {
                    child = RecursiveControlFind(nestedControl, controlID);
                    if (child != null)
                        break;
                }
            }
        }
        return child;
    }

Upvotes: 2

Rubens Farias
Rubens Farias

Reputation: 57976

Control.FindControl Method but it isn't recursive.

Upvotes: 0

Related Questions