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 ...
随机推荐
- 一步步写STM32 OS【二】环境搭建
一.安装IAR for ARM6.5 二.新建工程 1.选择处理器:STM32F407VG,暂不使用FPU 2.必要的路径配置和宏定义 3.使用SWO重定向IO输出 4.使用ST-LINK仿真器 5. ...
- [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.2.4
(1). The singular value decomposition leads tot eh polar decomposition: Every operator $A$ can be wr ...
- Read ListViewItem content from another process z
Normal Windows GUI applications work with messages that are sent to a window or control and the cont ...
- STL总结之queue, priority_queue, stack
之所以把这三个容器放在一起,是因为他们都是容器适配器. STL中queue就是我们常用的FIFO队列,实现是一个容器适配器,这种数据结构在网络中经常使用. queue的模板声明: templa ...
- HDU 3342
#include<stdio.h> #include<string.h> int degree[101],vis[101],map[101][101]; int main() ...
- 使用yum和iso镜像离线升级RedHat系统
创建一个用于挂载iso镜像的目录.由于这个目录不能在挂载时自动创建,所以需要以root身份先创建一个目录.命令: mkdir mount_dir 以root身份把iso镜像挂载到上一步创建的目录上.命 ...
- WordPress模版结构
一套完整的WordPress模版应至少包括如下文件: style.css : 样式表文件 index.php : 首页模板 archive.php : 文章归档/分类目录模板 404.php : 40 ...
- Word恢复文本转换器-修复损坏的WORD文件
第一步:找任意一个未损坏的文件打开word,新建的或者是已有的好的word文档,在文档的工具-选项-常规中,选中“打开时确认转换”复选框,并按确定. 第二步:点击word软件左上角的 文件-打开,找到 ...
- NSDictionary或NSArray与JSON字符串相互转换
在iOS 5 中,苹果引入了一个解析JSON串的NSJSONSerialization类.通过该类,我们可以完成JSON数据与NSDictionary和NSArray之间的转化. 以前,我记得我用的是 ...
- 七行jquery代码实现图片渐变切换【兼容ie6+、 Chrome、 Firefox】
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...