2014-12-13 28 views
1

我需要找到裏面的iframe如何讓所有的iframe ASP.NET內

所有控件如下面的方法找到控制.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 ...

我該怎麼做?

回答

0

嘗試閱讀字符串生成器中的.aspx頁面,然後使用正則表達式查找控件的id和文本