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. Advertising

  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. Advertising

  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. 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. Mad Scientist Jr
    Replies:
    0
    Views:
    625
    Mad Scientist Jr
    Mar 22, 2006
  2. Alec S.
    Replies:
    10
    Views:
    10,088
    Alec S.
    Apr 16, 2005
  3. Replies:
    2
    Views:
    3,191
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Oct 9, 2006
  4. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    530
    Jonathan Wood
    Feb 2, 2010
  5. Terence

    Conditional user interface in ASP.NET

    Terence, Oct 28, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    139
    Oliver
    Oct 29, 2003
Loading...

Share This Page