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

RadAjaxManager and Dynamically loaded controls

1 Answer 130 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
bogdan
Top achievements
Rank 1
bogdan asked on 23 Jun 2012, 08:13 AM
Hello.
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;
          cph.Controls.Clear();
          cph.Controls.Add(uc);
          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();                            
     args.set_cancel(true);
     break;
 case 1: //Company
     break;
 case 2: //Group
     var arr = GetSelectedGroups();
    break;

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
0
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:
http://www.telerik.com/help/aspnet-ajax/ajax-load-user-controls.html
http://demos.telerik.com/aspnet-ajax/ajax/examples/common/loadingusercontrols/defaultcs.aspx


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.
Tags
Ajax
Asked by
bogdan
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or