Asp.Net 如何获取所有控件&如何获取指定类型的所有控件
一、
Asp.Net Page页面中访问所有控件的属性为:
Page.Controls
控件的结构是树结构。
二、获取指定类型所有控件实例:
1.递归方法定义:
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);
}
}
2.使用调用:
List<Literal> allControls = new List<Literal>();
GetControlList<Literal>(Page.Controls, allControls);
foreach (var childControl in allControls)
{
//call for all controls of the page
}
Asp.Net 如何获取所有控件&如何获取指定类型的所有控件的更多相关文章
- WPF中查找指定类型的父控件
/// <summary> /// 查找父控件 /// </summary> /// <typeparam name="T"></type ...
- delphi ----寻找控件,以字符串类型的名称控件
vari :Integer;beginfor i := 1 to 10 do(FindComponent('Edit'+inttostr(i)) as TEdit).Text := inttostr( ...
- monkeyrunner之坐标或控件ID获取方法(六)
Monkeyrunner的环境已经搭建完成,现在对Monkeyrunner做一个简介. Monkeyrunner工具提供了一套API让用户/测试人员来调用,调用这些api可以控制一个Android设备 ...
- .net dataGridView当鼠标经过时当前行背景色变色;然后【给GridView增加单击行事件,并获取单击行的数据填充到页面中的控件中】
1.首先在前台dataGridview属性中增加onRowDataBound属性事件 2.然后在后台Observing_RowDataBound事件中增加代码 protected void Obser ...
- javascript客户端遍历控件与获取父容器对象
javascript客户端遍历控件与获取父容器对象示例代码 1,遍历也面中所有的控件function findControlAll() { var inputs=document. ...
- WPF silverlight获取子控件(获取DataTemplate里的子控件)
public static class VisualTreeExtensions { /// <summary> /// 获取父节点控件 /// </summary> /// ...
- NX二次开发-Block UI C++界面Specify Point(指定点)控件的获取(持续补充)
Specify Point(指定点)控件的获取 NX9+VS2012 #include <uf.h> #include <uf_ui.h> UF_initialize(); / ...
- NX二次开发-Block UI C++界面Face Collector(面收集器)控件的获取(持续补充 )
Face Collector(面收集器)控件的获取 NX9+VS2012 #include <uf.h> #include <uf_obj.h> UF_initialize() ...
- NX二次开发-Block UI C++界面Object Color Picker(对象颜色拾取器)控件的获取(持续补充)
Object Color Picker(对象颜色拾取器)控件的获取 NX9+VS2012 #include <uf.h> #include <uf_obj.h> UF_init ...
随机推荐
- 用css控制cellspacing、cellpadding
用css控制cellspacing.cellpadding 发表于 2006 年 12 月 24 日 由 Silbo 在table中控制单元格之间的间距要用到cellspacing.cellpaddi ...
- nginx错误汇总
一.Nginx出现413 Request Entity Too Large错误解决方法 Nginx出现的413 Request Entity Too Large错误,这个错误一般在上传文件的时候出现, ...
- 使用页面对象模型(pageFactory)
页面对象模型可以使测试脚本有更高癿可维护性,减少了重复癿代码,把页面抽象出来. 页面对象设计模式提供了测试一个接口,测试可以像用户行为一样来操作页面. 通过隐藏页面元素定位,返有劣将测试代码和页面分离 ...
- selenium1.0和selenium2.0页面等待处理详解
一.selenium1.0页面等待 1.……AndWait 经常会看到, selenium action命令中很多有这种……AndWait后缀, 例如click和clickAndWait命令: cli ...
- git日常操作
0.准备工作 0.1 git安装 http://git-scm.com/download/ 图形客户端建议使用source tree,中文界面 http://www.sourcetreeapp.c ...
- Apple LLVM 6.0 Warning: profile data may be out of date
I have no clue what this meant, so I googled the problem. I only ended up with some search results s ...
- unexpected error ConnectionError object has no attribute
unexpected error ConnectionError object has no attribute
- https://lua-toolbox.com/
Lua Toolbox https://github.com/bungle/lua-resty-session
- 使用Jquery.load()方法,出现-此页的状态信息无效,可能已损坏。[转]
今天遇到此页的状态信息无效,可能已损坏,在以下页面找到解决办法,特记录下来: 转自:http://www.cnblogs.com/liuwenlong/archive/2011/05/09/20410 ...
- Worker工作者进程