当前位置:编程学习 > C#/ASP.NET >>

asp.net 遍历一个所有控件

遍历一个用户控件里的所有控件

 /// <summary>
        /// 找控件
        /// </summary>
        /// <param name="ctlID">控件ID</param>
        /// <param name="ctlColl">控件集合</param>
        /// <returns></returns>
        public Control FindControlPoint(string ctlID, ControlCollection ctlColl)
        {
            Control retCtl = null;
            foreach (Control cc in ctlColl)
            {
                if (cc.ID == ctlID)
                {
                    retCtl = cc;
                    break;
                }
                retCtl = FindControlPoint(ctlID, cc.Controls);
                if (null != retCtl)
                {
                    break;
                }
            }
            return retCtl;
        }

补充:asp.net教程,.Net开发
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,