Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Assign an attribute to all my web controls

Reply
Thread Tools

Assign an attribute to all my web controls

 
 
Diego
Guest
Posts: n/a
 
      06-21-2004
Hi,
I want assing an attribute to all my web controls, i thought with
Page.Controls property but i donīt know how that works.
How can i iterate Page.Controls and set an attribute like Enable=false in
all my web controls?????


 
Reply With Quote
 
 
 
 
JezB
Guest
Posts: n/a
 
      06-22-2004
You have to parse the Controls collection of your Page object, but bear in
mind that some controls have their own Controls collection for sub-items so
your routine has to be recursive.

"Diego" <> wrote in message
news:...
> Hi,
> I want assing an attribute to all my web controls, i thought with
> Page.Controls property but i donīt know how that works.
> How can i iterate Page.Controls and set an attribute like Enable=false in
> all my web controls?????
>
>



 
Reply With Quote
 
 
 
 
JezB
Guest
Posts: n/a
 
      06-22-2004
Something like :

private void ParseControls (Control c)
{
// do something to the control, (but not the whole Page?)
if (!(c is Page)) c.Enabled = false;

// Now loop through any child controls (but not for populated datagrids)
if (c.HasControls())
{
foreach (Control ch in c.Controls)
{
ParseControls(ch);
}
}
}

then just call it and pass it your Page.

"Diego" <> wrote in message
news:...
> Hi,
> I want assing an attribute to all my web controls, i thought with
> Page.Controls property but i donīt know how that works.
> How can i iterate Page.Controls and set an attribute like Enable=false in
> all my web controls?????
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to assign an attribute to an inherited field from base class Florian Paulus ASP .Net 1 09-04-2008 03:26 PM
How to assign csssytle attribute to html elements through code? Zdenko Rupcic ASP .Net 2 09-25-2006 01:22 PM
basic: asp.net user controls: how to programmatically add attribute to all text box controls? ASP .Net 4 11-09-2005 02:14 AM
assign dynamic attributes in web controls in aspx file Diego ASP .Net Web Controls 4 06-21-2004 02:52 PM
assign dynamic attributes in web controls in aspx file DCV via .NET 247 ASP .Net Web Controls 0 06-17-2004 10:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57