【问题标题】:How to get all the controls inside iframe ASP.NET如何获取 iframe ASP.NET 中的所有控件
【发布时间】:2014-12-13 17:33:40
【问题描述】:

我需要在 iframe 中找到所有控件

例如下面的方法查找 .aspx 页面内的所有控件

private void GetControlList<T>(ControlCollection controlCollection, List<T>  resultCollection)
where T : Control
{
    foreach (Control control in controlCollection)
    {
        //if (control.GetType() == typeof(T))
        if (control is T) // This is cleaner
            resultCollection.Add((T)control);

        if (control.HasControls())
            GetControlList(control.Controls, resultCollection);
    }
}

像上面的方法一样,我需要 iframe .... 所以我尝试了下面的java脚本

function find() {
    var iframe = document.getElementById('frame');
    var innerDoc = (iframe.contentDocument) ? 
                 iframe.contentDocument : 
                 iframe.contentWindow.document;
    var dd = innerDoc.getElementById('label1').innerHTML;
}

但我需要传递控制 ID ...

我该怎么做?

【问题讨论】:

    标签: javascript c# asp.net iframe


    【解决方案1】:

    尝试在字符串生成器中读取 .aspx 页面,然后使用 Regex 查找控件的 id 和文本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      • 2021-12-23
      • 2010-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多