This is a migrated thread and some comments may be shown as answers.

Load UserControl in UserControl

4 Answers 63 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
hesam
Top achievements
Rank 1
hesam asked on 30 Jul 2009, 11:18 AM
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

4 Answers, 1 is accepted

Sort by
0
hesam
Top achievements
Rank 1
answered on 01 Aug 2009, 03:42 AM
hi
any body think about me?
0
Veli
Telerik team
answered on 05 Aug 2009, 07:14 AM
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.
0
hesam
Top achievements
Rank 1
answered on 10 Aug 2009, 07:30 AM

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

0
Veli
Telerik team
answered on 11 Aug 2009, 10:27 AM
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.
Tags
Ajax
Asked by
hesam
Top achievements
Rank 1
Answers by
hesam
Top achievements
Rank 1
Veli
Telerik team
Share this question
or