all groups > vj# > april 2005 >
You're in the

vj#

group:

WebControls objects



WebControls objects GH
4/21/2005 12:21:02 PM
vj#: I'm pretty new to .net and I'm hoping someone can help me. I have an asp
page that contains many webcontrols objects, for example WebControls.TextBox

Is there a way for me to get a "collection" of webcontrols object that are
contained on a page? I'd like to be able to loop thru the collection and
examine properties of the control objects as I encounter them. Getting each
control by name is not really an option for me unless there is a way to get
the list of names.

RE: WebControls objects Geoff Halsted
4/21/2005 2:45:04 PM
In response to my question below I believe something like this will work:
StringBuffer sb = new StringBuffer();
ControlCollection cc = this.get_Controls();
Control c = cc.get_Item(1);
ControlCollection ccc = c.get_Controls();
for (int i=0; i<ccc.get_Count(); i++)
{ if (ccc.get_Item(i).get_ID() != null)
sb.append(ccc.get_Item(i).get_ID() + ",");
}
System.out.println(sb.toString());

[quoted text, click to view]
Re: WebControls objects Lars-Inge Tønnessen [VJ# MVP]
5/11/2005 12:00:00 AM

Please remember this will only list the controls that are on the first
panel. If you have multiple panels on top of each other, or controls on
controls, you must do a recusive search through the controls (yes, you can
also do a iterative search).

Do you know how to do this, or do you want an example?


Regards,
Lars-Inge Tønnessen

AddThis Social Bookmark Button