【发布时间】: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