C#中的jscript document.getElementsByName

时间:2011-05-26 00:10:04

标签: c# javascript .net dom

在c#中类似吗?

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

2 个答案:

答案 0 :(得分:2)

递归FindControl方法:

    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;
    }

答案 1 :(得分:0)

Control.FindControl Method但它不是递归的。