control disable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    control disable

    hi, how to disable the controls in page? thanks

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


  • Chris

    #2
    Re: control disable

    js@someone.com wrote:[color=blue]
    > hi, how to disable the controls in page? thanks
    >
    > For each myControl in Page.Controls
    > 'want to disable myControl?
    > Next
    >
    >[/color]

    For each myControl in Page.Controls
    'want to disable myControl?
    myControl.Enabl ed = False
    Next

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: control disable

      js,

      Have a look at the uper part of this sample.



      and than instead of that addhanlder

      ctr.enabled = false

      However in this is probably
      me.enabled = false

      easier.

      Cor


      Comment

      • js

        #4
        Re: control disable

        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.Enabl ed = False
        Next

        How to fix it? Thanks.

        "Chris" <no@spam.com> wrote in message
        news:eq5AJIGMGH A.2316@TK2MSFTN GP11.phx.gbl...[color=blue]
        > js@someone.com wrote:[color=green]
        >> hi, how to disable the controls in page? thanks
        >>
        >> For each myControl in Page.Controls
        >> 'want to disable myControl?
        >> Next[/color]
        >
        > For each myControl in Page.Controls
        > 'want to disable myControl?
        > myControl.Enabl ed = False
        > Next[/color]


        Comment

        • Cerebrus99

          #5
          Re: control disable

          Hi Js,

          Instead of declaring myControl as Control, try declaring it as WebControl
          (System.Web.UI. WebControls.Web Control). 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.Enabl ed = False
          Next
          ------------------------

          Hope this helps...

          Regards,
          Cerebrus.


          "js" <js@someone.com > wrote in message
          news:OksqowKMGH A.552@TK2MSFTNG P10.phx.gbl...[color=blue]
          > 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.Enabl ed = False
          > Next
          >
          > How to fix it? Thanks.
          >
          > "Chris" <no@spam.com> wrote in message
          > news:eq5AJIGMGH A.2316@TK2MSFTN GP11.phx.gbl...[color=green]
          > > js@someone.com wrote:[color=darkred]
          > >> hi, how to disable the controls in page? thanks
          > >>
          > >> For each myControl in Page.Controls
          > >> 'want to disable myControl?
          > >> Next[/color]
          > >
          > > For each myControl in Page.Controls
          > > 'want to disable myControl?
          > > myControl.Enabl ed = False
          > > Next[/color]
          >
          >[/color]


          Comment

          • Cor Ligthert [MVP]

            #6
            Re: control disable

            Js,

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



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

            Sorry, I did not see it direct,

            I hope this helps,

            Cor


            Comment

            • js

              #7
              Re: control disable

              Thanks Cor.

              "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
              news:uema1HNMGH A.536@TK2MSFTNG P09.phx.gbl...[color=blue]
              > Js,
              >
              > I see now that it is a webform, that is this tip.
              >
              > http://www.vb-tips.com/default.aspx?...8-ec5d24c916a6
              >
              > And than the same as I wrote in the previous message.
              >
              > Sorry, I did not see it direct,
              >
              > I hope this helps,
              >
              > Cor
              >[/color]


              Comment

              Working...