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

RadAjaxManager and Dynamically loaded controls

1 Answer 130 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
bogdan asked on 23 Jun 2012, 08:13 AM
I have a MasterPage setup in a Web Application.
Based on different button clicks i load dynamically different usercontrols in a contentplaceholder.

ContentPlaceHolder cph = this.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
      UserControl uc = this.LoadControl("~/UserControls/" + strName + ".ascx") as UserControl;
      if ((cph != null) && (uc != null))
          uc.ID = strName;
          IsControlAdded = true;
          ViewState[IDS_USERCONTROL] = strName;

The problem is that i need in Site.Master to use some js code that exists in a dynamically loaded usercontrol.
That seems to be no problem for the first loaded usercontrol because the usercontrols html is included in the master page html.
The problem arrises when i dynimically load the second usercontrol i find out that the html and js from the first usercontrol loaded persists in the master page and the second usercontrol's js and html is not loaded.

If i add EnableAJAX="false" to the radajaxmanager it solves my problem .. but then again .. that beats the purpose of using ajaxmanager.
switch (index) {
 case 0: //Person
     var arr = GetSelectedPerson();                            
 case 1: //Company
 case 2: //Group
     var arr = GetSelectedGroups();

This is a code snipplet from Site.Master
GetSelectedPerson and GetSelectedGroups are two js methods that exist in different usercontrols.

1 Answer, 1 is accepted

Sort by
Maria Ilieva
Telerik team
answered on 27 Jun 2012, 08:38 PM
Hello Bogdan,

Please ensure that you are loading the UserControls correctly as described in the online resources below:

All the best,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Asked by
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question