Hi,

Is there a way to read witch WebControl (like TextBox's) and howmany
webcontrols are in a WebForm?

Re: WebForm read by Darren

Darren
Mon Sep 26 16:15:35 CDT 2005

Well yes. Typically you can reference a control by it's ID, so if you
have a textbox webcontrol on the page that's id is txtFirstBox, you can
reference that control by that name. For instance you can access the
text property of the text box by txtFirstBox.Text.

Another way you can access a control on the page is through the find
command. You can do this like so - Page.FindControl("controlname").

This is how you can find controls that are in the page collection
(finding controls contained in other web controls can be found in a
similar manner).

You can access how many web controls are on the page through
Page.Controls.Count.

Hope this helps,
Darren Kopp


Re: WebForm read by italo

italo
Tue Sep 27 07:40:05 CDT 2005

Thank you Darren.. a half of my doubts are ok.

Can i put in a Label, for example, the numbers of TextBox in a
WebForm??
if yes, how can i do this?

im sorry if its a Newbie question :)

Great Regards.
Italo M=E1cola


Re: WebForm read by italo

italo
Tue Sep 27 08:49:54 CDT 2005

Thats it :)
we found a way to do it. with FindControl and Controls.
its in C#, im counting the number of TextBox's and cleaning them.
i think its okai.

Control frm =3D new Control();
frm =3D Page.FindControl("Form1");
int i =3D 0;
foreach (Control clt in frm.Controls)
{
i +=3D 1;
TextBox tb =3D new TextBox();
if (clt is TextBox)
{
tb =3D (TextBox)clt;
tb.Text =3D "";
}
}

thank you for your help one more time ;)

King Regards.
Italo M=E1cola


Re: WebForm read by Darren

Darren
Tue Sep 27 14:50:41 CDT 2005

Great to hear that you found a way to do it.

-Darren