How to load different user control - Call made from control being replaced

Discussion in 'ASP .Net' started by moondaddy, May 4, 2004.

  1. moondaddy

    moondaddy Guest

    I need to replace a user control on a page with a different user control.
    The challenge I'm faced with is that this call is being made from the user
    control being replaced.

    Normally I replace one user control with another user control like this
    'Using vb.net 1.1

    ctl = LoadControl(ctlPath)
    Me.cellControlHolder.Controls.Clear()
    Me.cellControlHolder.Controls.Add(ctl)


    However, here's the unique scenario I'm working with now: The main (parent)
    page is default.aspx and in Me.cellControlHolder (in default.aspx) I've
    loaded ShoppingCart.ascx. Now in the shoppingcart control a user clicked on
    a the checkout button and in that onclick event I found that the user hasn't
    logged in yet. So now I want to replace the shopping cart user control with
    the Login.ascx user control. But keep in mind that this code is running in
    the shopping cart control. In an nutshell I need to call a method from in
    the shoppingcart control to its parent (default.aspx) and this method will
    run this:

    ctlPath="blablabla/Login.ascx"
    ctl = LoadControl(ctlPath)
    Me.cellControlHolder.Controls.Clear()
    Me.cellControlHolder.Controls.Add(ctl)

    Any great ideas on how to do this?

    --
     
    moondaddy, May 4, 2004
    #1
    1. Advertising

  2. moondaddy

    moondaddy Guest

    This trick has a pretty good success rate. If I can't figure out something
    even if my life depened on it, post a question to the user groups and it
    will automaticly come to my mind. I figured it out and here' how:


    'Note: this code is running in the shoppingcart user control and is located
    in a table cell called "cellControlHolder"on the default page.
    Dim ctlHolder As Control
    Dim ctl As UserControl

    Dim ctlPath As String = "Login.ascx"
    ctlHolder = Me.Parent ' me.parent is "cellControlHolder"

    ctl = LoadControl(ctlPath)
    ctlHolder.Controls.Clear()
    ctlHolder.Controls.Add(ctl)





    --

    "moondaddy" <> wrote in message
    news:...
    > I need to replace a user control on a page with a different user control.
    > The challenge I'm faced with is that this call is being made from the user
    > control being replaced.
    >
    > Normally I replace one user control with another user control like this
    > 'Using vb.net 1.1
    >
    > ctl = LoadControl(ctlPath)
    > Me.cellControlHolder.Controls.Clear()
    > Me.cellControlHolder.Controls.Add(ctl)
    >
    >
    > However, here's the unique scenario I'm working with now: The main

    (parent)
    > page is default.aspx and in Me.cellControlHolder (in default.aspx) I've
    > loaded ShoppingCart.ascx. Now in the shoppingcart control a user clicked

    on
    > a the checkout button and in that onclick event I found that the user

    hasn't
    > logged in yet. So now I want to replace the shopping cart user control

    with
    > the Login.ascx user control. But keep in mind that this code is running

    in
    > the shopping cart control. In an nutshell I need to call a method from in
    > the shoppingcart control to its parent (default.aspx) and this method will
    > run this:
    >
    > ctlPath="blablabla/Login.ascx"
    > ctl = LoadControl(ctlPath)
    > Me.cellControlHolder.Controls.Clear()
    > Me.cellControlHolder.Controls.Add(ctl)
    >
    > Any great ideas on how to do this?
    >
    > --
    >
    >
    >
     
    moondaddy, May 4, 2004
    #2
    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. GeekBoy

    Load balancing made simple?

    GeekBoy, Oct 22, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    602
    John Timney \(Microsoft MVP\)
    Oct 25, 2004
  2. Shawn Modersohn

    replaced vs non replaced

    Shawn Modersohn, Jul 19, 2004, in forum: HTML
    Replies:
    4
    Views:
    982
    Shawn Modersohn
    Jul 20, 2004
  3. Paul Carter

    Wse call just not being made when part of a domain

    Paul Carter, Feb 27, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    115
    Paul Carter
    Feb 27, 2007
  4. Nigama Xx
    Replies:
    1
    Views:
    86
    Sebastian Hungerecker
    Dec 12, 2007
  5. Tim Streater

    Preventing history entries being made

    Tim Streater, Mar 2, 2007, in forum: Javascript
    Replies:
    0
    Views:
    113
    Tim Streater
    Mar 2, 2007
Loading...

Share This Page