conditional user control

Discussion in 'ASP .Net' started by suzy, May 12, 2004.

  1. suzy

    suzy Guest

    hi,

    how do i show/hide a user control depending on a condition. i can't write
    an IF statement because im referencing the user control from html.

    i am thinking of putting a panel control on my html instead of the
    usercontrol, then adding the user control to it at runtime (depending on
    condition). is this the best way?

    thanks.
     
    suzy, May 12, 2004
    #1
    1. Advertisements

  2. suzy

    Paul Guest

    In class file, you declare usercontrol like
    Protected WithEvents muControl As ucControl

    Then, set it false.

    muControl.Visible = False



    "suzy" <> wrote in message
    news:%...
    > hi,
    >
    > how do i show/hide a user control depending on a condition. i can't write
    > an IF statement because im referencing the user control from html.
    >
    > i am thinking of putting a panel control on my html instead of the
    > usercontrol, then adding the user control to it at runtime (depending on
    > condition). is this the best way?
    >
    > thanks.
    >
    >
    >
     
    Paul, May 12, 2004
    #2
    1. Advertisements

  3. Hi, Suzy, Paul

    Suzy has mentioned that she needs to refer it in HTML code. If a server control is set to invisible, it will not be rendered to the client-side and can not be refered in client side scripting
    You might try to add a panel and add your user control on it and then set the panel's style, like
    Panel1.Style("visibility") = "hidden"
    o
    Panel1.Style("display") = "none

    Bin Son
     
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 12, 2004
    #3
  4. suzy

    Curt_C [MVP] Guest

    IIRC you can use LoadControl() to dynamically load a control, thereby making
    it conditional.

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "suzy" <> wrote in message
    news:%...
    > hi,
    >
    > how do i show/hide a user control depending on a condition. i can't write
    > an IF statement because im referencing the user control from html.
    >
    > i am thinking of putting a panel control on my html instead of the
    > usercontrol, then adding the user control to it at runtime (depending on
    > condition). is this the best way?
    >
    > thanks.
    >
    >
    >
     
    Curt_C [MVP], May 12, 2004
    #4
    1. Advertisements

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. Tom Rowton
    Replies:
    2
    Views:
    897
    Tom Rowton
    Aug 1, 2003
  2. vatech1993
    Replies:
    4
    Views:
    5,884
    =?Utf-8?B?U8Opcmdpbw==?=
    Dec 11, 2004
  3. Replies:
    0
    Views:
    579
  4. Don
    Replies:
    3
    Views:
    5,682
    Karl Seguin
    Mar 11, 2005
  5. Mad Scientist Jr
    Replies:
    0
    Views:
    873
    Mad Scientist Jr
    Mar 22, 2006
  6. Alec S.
    Replies:
    10
    Views:
    11,180
    Alec S.
    Apr 16, 2005
  7. Replies:
    2
    Views:
    3,392
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Oct 9, 2006
  8. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    794
    Jonathan Wood
    Feb 2, 2010
Loading...