Re: Problems with PostBack events when swapping dynamically loaded controls in a page

Discussion in 'ASP .Net' started by Peter Jaffe, Feb 4, 2004.

  1. Peter Jaffe

    Peter Jaffe Guest

    Turned out that setting an explicit ID value on the dynamically
    loaded user controls avoids the automatic id generation that was
    causing the problem.

    All set now.


    "Peter Jaffe" <> wrote in message
    news:...
    > I'm hoping that someone might be able to shed some light on this one...
    >
    > Design Goal: Use a single page to host a series of dynamically loaded
    > UserControls. Each UserControl will handle its own postback events, and
    > raise events to the page which will orchestrate loading the next control.
    >
    > First Post Back Works: The initial page is rendered with UserControl A as
    > the first (and only) control in the naming container so its UniqueID is
    > _ctl0. On the postback, UserControl A is the first control added so its
    > uniqueID is again _ctl0.
    >
    > Problem: During the second postback, UserControl B fails to be notified of
    > its postback event.
    >
    > My Current Hypothesis: It seems that during the first postback, even

    though
    > UserControl A is removed from the naming container before UserControl B is
    > added, UserControl B's UniqueID is _ctl1 instead of _ctl0. During the
    > second postback, UserControl B is added first hoping that it will handle

    its
    > postback events, but it is added with the UniqueID of _ctl0 which doesn't
    > line up with the UniqueID of the submitted page. Or maybe I am chasing a
    > red-hearing with the UniqueID issue, and maybe it is the ViewState that is
    > messing it up...
    >
    > Possible Root Cause: Maybe the ControlCollection._size private instance
    > variable in the framework isn't being decremented when Remove(control) is
    > called? This is was a thought after staring at decompiled .NET framework
    > code for awhile...
    >
    > Any help would be appreciated.
    >
    > Attached is my test code:
    > MasterPage.aspx - contains a placeholder for UserControl A and B
    > respectively and controls the flow
    > UserControlA.ascx - Renders a TextBox and a button. Event handler for

    the
    > button raises an event to the MasterPage.
    > UserControlB.ascx - Renders a TextBox and a button. Event handler for

    the
    > button raises an event to the MasterPage.
    >
    > A successful transition should flip between rendering each UserControl

    and
    > should pass along any text in the Text box and prepend with "Data From..."
    >
    > MasterPageNoSwap.aspx - Simple Page that works since it just continually
    > loads the same UserControlA
    >
    > Thanks in advance!
    >
    > Pete
    >
    >
    >
     
    Peter Jaffe, Feb 4, 2004
    #1
    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. Danny Bloodworth

    Events in dynamically loaded user controls

    Danny Bloodworth, Nov 20, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    558
  2. Alan Silver
    Replies:
    6
    Views:
    2,875
    Alan Silver
    Aug 9, 2005
  3. =?Utf-8?B?V291dGVy?=

    Dynamically Loaded controls loading other controls

    =?Utf-8?B?V291dGVy?=, Feb 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    501
    =?Utf-8?B?V291dGVy?=
    Feb 27, 2006
  4. sonic_soul
    Replies:
    2
    Views:
    132
    Himanshu Dhami
    Aug 14, 2003
  5. Wael_Bakr

    stop postback in postback events for server controls ??

    Wael_Bakr, Nov 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    503
    Wael_Bakr
    Nov 30, 2005
Loading...

Share This Page