Load UserControl in UserControl

5 posts, 0 answers
  1. hesam
    hesam avatar
    26 posts
    Member since:
    May 2008

    Posted 30 Jul 2009 Link to this post

    hi
    in my project i want in first usercontrol bind a treeview and click on treeview show me other user control.
    now. i don't know how i can that because second user control in postbak is hidden and treeview in postbak and !postbackĀ rebinded.

    my sample project


    http://www.telerik.com/help/aspnet-ajax/grdusercontrolruntimeload.html
    http://www.telerik.com/help/aspnet/ajax/ajxshowhideloadingpanel.html
    http://www.telerik.com/help/aspnet-ajax/ajxloadusercontrols.html
    http://demos.telerik.com/aspnet-ajax/ajax/examples/manager/usercontrol/defaultcs.aspx

    please help me
    thank a lot
  2. hesam
    hesam avatar
    26 posts
    Member since:
    May 2008

    Posted 31 Jul 2009 Link to this post

    hi
    any body think about me?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 05 Aug 2009 Link to this post

    Hi hesam,

    I am not sure I understand your question. You need to add dynamically a user control on the page from an event in another user control. Do you have difficulties with being unable to add the user control, or you have problems with RadTreeView and its server-side event in which you add another user control.

    If you cannot add a user control from another user control, try the following. Find your container control that will hold your second control in the Page object:

    (Page.FindControl("SecondControlPanel"as Panel).Controls.Add(mySecondUserControl); 

    Kind regards,
    Veli
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. hesam
    hesam avatar
    26 posts
    Member since:
    May 2008

    Posted 10 Aug 2009 Link to this post

    hi
    if you see that my sample i add usercontrol to content place holder in masterpage whit menu and in that user control when click on tree then add other user control in place holder in user control when that added tree have not value

    if for you possible see that sample
    thank's a lot

  6. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 11 Aug 2009 Link to this post

    Hi hesam,

    The reason you do not get your second nested control persisted, is because you recreate your first nested control in the click event of a menu item. As this event is fired after the page has saved its viewstate, you do not get your second control's viewstate properly initialized.

    In short, the second control's ID that you save in the first control's CurrentControl property is lost. The work around this, you need to save both the outer and inner control's IDs to the MasterPage's ViewState. Attached is a reworked version of the sample project you sent me. You can see that I now access the master page through the content page inside the user controls and use the master page's properties only, so that I make sure the ViewState is properly maintained.

    Additionally, with your AJAX manager, you hava AJAX-ified the entire content place holder for the user controls. Therefore, you do not need to place additional AJAX settings with the RadAjaxManagerProxy inside the user controls. On the contrary, the AJAX behavior breaks up if you do so.

    Kind regards,
    Veli
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017