获取Web控件的名称 [英] get the name of web controls

查看:100
本文介绍了获取Web控件的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在asp.net中加载页面时,我想获取每个Web控件的名称.

请帮帮我.

"this"对象显示所有控件,但是当我尝试this.form.controls时;我只得到html控件

谢谢

Hi,

I want to get the names of each web controls while loading the page in asp.net.

Please help me.

The "this" object shows all the controls but when I tried this.form.controls; I''m getting only html controls

Thank you

推荐答案

在所有asp.net控件上指定runat ="server"以便从form.controls访问它.
在System.Web.UI.HTMLControl类中,该属性不是必需的.
但是,在System.Web.UI.WebControl类中,该属性是必需的.
Specify runat="server" on all asp.net controls to access it from form.controls.
In the class System.Web.UI.HTMLControl, the attribute is not required.
However, in the class System.Web.UI.WebControl the attribute is required.


请使用以下
Please use following
foreach (Control ctrl in this.Controls)
       {
       }



谢谢,
Imdadhusen



Thanks,
Imdadhusen


这篇关于获取Web控件的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆