Problem with loading UserControls dynamically.

Discussion in 'ASP .Net' started by Sundaresan, Nov 20, 2003.

  1. Sundaresan

    Sundaresan Guest

    I've a form where I load two user controls dynamically.

    User Control-1 has a no.of dropdowns and based on the
    selection I typically
    populate a datagrid in the user control-2,

    Also the I could be loading a different usercontrol-2
    based on the selections in usercontrol-1.

    Also I thought of passing the selection values through
    public properties of the usercontrols without
    resorting to querystrings or session variables.

    So I've decided to load the UserControl-1 in Page_Load and
    Load UserControl-2 in Page_Prerender
    So that the postback on usercontrol-1 is processed and the
    properties of usercontrol-2 are set
    properly before it loads.

    This works just fine, until I've a requirement where I
    need to post back from the datagrid in user_control2.
    Those events just won't fire ( probably because I'm always
    loading the usercontrol-2 in PreRender ).

    On the other hand, If I try to load both user controls in
    page load, UserControl-2 would not know any thing
    about the usercontrol-1's server controls Current
    selection.

    Can some one straighten out this design problem for me ?
    Appreciate your help.

    -Sundar
    Sundaresan, Nov 20, 2003
    #1
    1. Advertising

  2. Sundaresan

    Natty Gur Guest

    Hi,

    try to use the override OnInit method and page_load. using those methods
    won't harm postback behavior.

    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, Nov 23, 2003
    #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. Hendrik W. Hansen

    Loading UserControls dynamically

    Hendrik W. Hansen, Oct 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    414
    Hendrik W. Hansen
    Oct 28, 2003
  2. Brett
    Replies:
    1
    Views:
    483
    Brett
    Sep 9, 2004
  3. Darrel
    Replies:
    3
    Views:
    3,931
    Darrel
    Nov 8, 2004
  4. ujjc001
    Replies:
    0
    Views:
    1,369
    ujjc001
    Jul 27, 2005
  5. Hendrik W. Hansen

    Dynamically loading and adding usercontrols after CreateChildControls

    Hendrik W. Hansen, May 28, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    390
Loading...

Share This Page