<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>
/// <summary><br> /// 采用递归的方法来遍历页面控件<br> /// </summary>
/// <param name="parent">
protected void ErgodicChildrenControls(Control parent)
{
foreach (Control c in parent.Controls)
{
//此处写有关控件的代码,例如
//if (c is HtmlInputButton)
// {
// HtmlInputButton btn = (HtmlInputButton)c;
// if (c.id =="save")
// {
// c.Visble=true;
// }
// }
if (c.Controls.Count > 0) // 判断该控件是否有下属控件。
{
ErgodicChildrenControls(c); //递归,访问该控件的下属控件集。
}
}
}
调用的方法:
protected void Page_Load(object sender, EventArgs e)
{
ErgodicChildrenControls(this);
}
注意:该方法只能遍历服务器(即 runat=server)控件