Home All Groups Group Topic Archive Search About
Author
13 Feb 2006 5:03 AM
js
hi, how to disable the controls in page? thanks

For each myControl in Page.Controls
    'want to disable myControl?
Next

Author
13 Feb 2006 5:55 AM
Chris
j*@someone.com wrote:
> hi, how to disable the controls in page? thanks
>
> For each myControl in Page.Controls
>     'want to disable myControl?
> Next
>
>

  For each myControl in Page.Controls
      'want to disable myControl?
    myControl.Enabled = False
  Next
Author
13 Feb 2006 2:45 PM
js
Hi,
I got compile error: "Enable" is not a membre of "System.Web.UI.Control",

Dim myControl as Control
For each myControl in Page.Controls
      'want to disable myControl?
      myControl.Enabled = False
Next

How to fix it? Thanks.

Show quoteHide quote
"Chris" <no@spam.com> wrote in message
news:eq5AJIGMGHA.2316@TK2MSFTNGP11.phx.gbl...
> j*@someone.com wrote:
>> hi, how to disable the controls in page? thanks
>>
>> For each myControl in Page.Controls
>>     'want to disable myControl?
>> Next
>
>  For each myControl in Page.Controls
>      'want to disable myControl?
> myControl.Enabled = False
>  Next
Author
13 Feb 2006 4:29 AM
Cerebrus99
Hi Js,

Instead of declaring myControl as Control, try declaring it as WebControl
(System.Web.UI.WebControls.WebControl). This class possesses the "Enabled"
property. This of course, assumes that you have only WebControls on your
page, and not HtmlControls etc. Also, not all WebControls support this
property, so you would have to be careful about what all you have on the
page. An alternative may be to put all the controls you want to disable,
into a Panel control and then use "For each myControl in Panel1.Controls"..

The code would then be :
------------------------
Dim myControl as WebControl
For each myControl in Page.Controls
     myControl.Enabled = False
Next
------------------------

Hope this helps...

Regards,
Cerebrus.


Show quoteHide quote
"js" <j*@someone.com> wrote in message
news:OksqowKMGHA.552@TK2MSFTNGP10.phx.gbl...
> Hi,
> I got compile error: "Enable" is not a membre of "System.Web.UI.Control",
>
> Dim myControl as Control
> For each myControl in Page.Controls
>       'want to disable myControl?
>       myControl.Enabled = False
> Next
>
> How to fix it? Thanks.
>
> "Chris" <no@spam.com> wrote in message
> news:eq5AJIGMGHA.2316@TK2MSFTNGP11.phx.gbl...
> > j*@someone.com wrote:
> >> hi, how to disable the controls in page? thanks
> >>
> >> For each myControl in Page.Controls
> >>     'want to disable myControl?
> >> Next
> >
> >  For each myControl in Page.Controls
> >      'want to disable myControl?
> > myControl.Enabled = False
> >  Next
>
>
Author
13 Feb 2006 6:56 AM
Cor Ligthert [MVP]
js,

Have a look at the uper part of this sample.

http://www.vb-tips.com/default.aspx?ID=8ff290d4-5c16-4cef-ba06-56e3599238c1

and than instead of that addhanlder

ctr.enabled = false

However in this is probably
me.enabled = false

easier.

Cor
Author
13 Feb 2006 7:16 PM
Cor Ligthert [MVP]
Js,

I see now that it is a webform, that is this tip.

http://www.vb-tips.com/default.aspx?ID=0e966f46-0381-4cec-82e8-ec5d24c916a6

And than the same as I wrote in the previous message.

Sorry, I did not see it direct,

I hope this helps,

Cor
Author
13 Feb 2006 9:39 PM
js
Thanks Cor.

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:uema1HNMGHA.536@TK2MSFTNGP09.phx.gbl...
> Js,
>
> I see now that it is a webform, that is this tip.
>
> http://www.vb-tips.com/default.aspx?ID=0e966f46-0381-4cec-82e8-ec5d24c916a6
>
> And than the same as I wrote in the previous message.
>
> Sorry, I did not see it direct,
>
> I hope this helps,
>
> Cor
>