Get All Web Controls of a Specific Type on a Page

后端 未结 8 1854
忘掉有多难
忘掉有多难 2020-12-01 03:58

I have been pondering how I can get all controls on a page and then perform a task on them in this related question:

How to Search Through a C# DropDownList Programm

8条回答
  •  借酒劲吻你
    2020-12-01 04:27

            var dropDownLists = new List();
            foreach (var control in this.Controls)
            {
                if (control is DropDownList)
                {
                    dropDownLists.Add( (DropDownList)control );
                }
            }
    

提交回复
热议问题