easy one again!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jorge Ribeiro

    #1

    easy one again!

    Hello

    I've an asp.net page that, of course, has serveral
    buttons,
    text boxes and other kind of controls in it...

    i need now to have them all disabled, or a lot of them,
    and i'm searching for the best/elegant way to do it...

    i managed to create a for cycle to iterate all the page's
    form's controls
    but usign page.controls.i tem(x) i can't find the enabled
    property... only visible one...

    how can i do this?!?!
    how can i disable a bunch of controls using a for next
    command instead of doing it one by one?!?!

    best regards

    JR
  • Marina

    #2
    Re: easy one again!

    If all your controls are web controls (have WebControl class as a base class
    somewhere in the inheritence hierarchy), you can cast it to WebControl in
    your loop, and have access to the Enabled property.

    "Jorge Ribeiro" <jorge.ribeiro@ irsocial.mj.pt> wrote in message
    news:043301c396 fc$f91cb900$a00 1280a@phx.gbl.. .[color=blue]
    > Hello
    >
    > I've an asp.net page that, of course, has serveral
    > buttons,
    > text boxes and other kind of controls in it...
    >
    > i need now to have them all disabled, or a lot of them,
    > and i'm searching for the best/elegant way to do it...
    >
    > i managed to create a for cycle to iterate all the page's
    > form's controls
    > but usign page.controls.i tem(x) i can't find the enabled
    > property... only visible one...
    >
    > how can i do this?!?!
    > how can i disable a bunch of controls using a for next
    > command instead of doing it one by one?!?!
    >
    > best regards
    >
    > JR[/color]


    Comment

    • Marina

      #3
      Re: easy one again!

      If all your controls are web controls (have WebControl class as a base class
      somewhere in the inheritence hierarchy), you can cast it to WebControl in
      your loop, and have access to the Enabled property.

      "Jorge Ribeiro" <jorge.ribeiro@ irsocial.mj.pt> wrote in message
      news:043301c396 fc$f91cb900$a00 1280a@phx.gbl.. .[color=blue]
      > Hello
      >
      > I've an asp.net page that, of course, has serveral
      > buttons,
      > text boxes and other kind of controls in it...
      >
      > i need now to have them all disabled, or a lot of them,
      > and i'm searching for the best/elegant way to do it...
      >
      > i managed to create a for cycle to iterate all the page's
      > form's controls
      > but usign page.controls.i tem(x) i can't find the enabled
      > property... only visible one...
      >
      > how can i do this?!?!
      > how can i disable a bunch of controls using a for next
      > command instead of doing it one by one?!?!
      >
      > best regards
      >
      > JR[/color]


      Comment

      Working...