Assign an attribute to all my web controls

Discussion in 'ASP .Net Web Controls' started by Diego, Jun 21, 2004.

  1. Diego

    Diego Guest

    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?????
    Diego, Jun 21, 2004
    #1
    1. Advertising

  2. Diego

    JezB Guest

    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?????
    >
    >
    JezB, Jun 22, 2004
    #2
    1. Advertising

  3. Diego

    JezB Guest

    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?????
    >
    >
    JezB, Jun 22, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    7,138
    Steven Cheng[MSFT]
    Nov 9, 2005
  2. Zdenko Rupcic
    Replies:
    2
    Views:
    569
    Zdenko Rupcic
    Sep 25, 2006
  3. Florian Paulus
    Replies:
    1
    Views:
    259
    bruce barker
    Sep 4, 2008
  4. DCV via .NET 247

    assign dynamic attributes in web controls in aspx file

    DCV via .NET 247, Jun 17, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    133
    DCV via .NET 247
    Jun 17, 2004
  5. Diego
    Replies:
    4
    Views:
    197
    Diego
    Jun 21, 2004
Loading...

Share This Page