How do I get rid of a usercontrol when I want to replace it withanother.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • COHENMARVIN@lycos.com

    How do I get rid of a usercontrol when I want to replace it withanother.

    I have some code like this:
    Dim control As Control
    control = Page.LoadContro l("../usercontrols/
    AlertsForQA.asc x")
    content.Control s.Add(control)
    'content' is the ID of a 'span' control. This is my way of adding
    usercontrols to a aspx page.
    Maybe there is a better way.
    Anyway, I find that I want to get rid of the user control at some
    point, and replace it with another user control. I could just do an
    'Add' of the new control, but that would not unload or otherwise get
    rid of the first control. Is there any way to get rid of the first
    control? Should I save the 'control' that I first added in a session
    variable so that I can somehow get rid of it later? Will the first
    control simply be removed if I do a postback and neglect to add it in
    page load?
    Thanks,
    Marv.
  • Lloyd Sheen

    #2
    Re: How do I get rid of a usercontrol when I want to replace it with another.


    <COHENMARVIN@ly cos.comwrote in message
    news:193bbda5-8d46-44ad-ae51-575395758c1c@34 g2000hsf.google groups.com...
    >I have some code like this:
    Dim control As Control
    control = Page.LoadContro l("../usercontrols/
    AlertsForQA.asc x")
    content.Control s.Add(control)
    'content' is the ID of a 'span' control. This is my way of adding
    usercontrols to a aspx page.
    Maybe there is a better way.
    Anyway, I find that I want to get rid of the user control at some
    point, and replace it with another user control. I could just do an
    'Add' of the new control, but that would not unload or otherwise get
    rid of the first control. Is there any way to get rid of the first
    control? Should I save the 'control' that I first added in a session
    variable so that I can somehow get rid of it later? Will the first
    control simply be removed if I do a postback and neglect to add it in
    page load?
    Thanks,
    Marv.
    When you do a postback the dynamic control is gone unless you add it in the
    pre-init.

    LS

    Comment

    Working...