Newbie: Loop through WebControls on a form - C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,
I've got a user control with a series of WebControl Buttons, rendered as
tabs (for WebForms). I'd like to loop through these buttons / tabs to set
their properties. I've used the foreach (Control objTab in this.Controls)
construct but it gave me an error "The type or namespace name 'Control' could
not be found ..." even though I've got the "using System.Web.UI.WebControls"
statement at the top of the page.
Have I done something wrong or is there some other ways of doing it? Can
someone enlighten me on this please.
Any suggestion is greatly appreciated.
Many thanks in advance.
KD
 
How about

foreach(WebControl control in this.Controls)

This will work

Regards,

Deepak
[I Code, therefore I am]
 
Back
Top