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

AjaxMngr, dynamic Loading Selected User Control which loads selected usercontrol back into Ajax Manager

3 Answers 236 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Neal
Top achievements
Rank 1
Neal asked on 27 May 2008, 03:19 PM
Tougher than normal one I guess.

I have a MngrForm (.aspx) which happily loads uctls, from Radmenu, one of which is a tabbed uctl,..no problem,..this loads different UCtls into each tab on page load. No Problem.

I then use AjaxifySelf to ajaxify the grids in each of these UCtls loaded into the Tabbed UCtl. eg.

private void AjaxifySelf()    {
   RadAjaxManager ajaxManager = (RadAjaxManager)Page.FindControl("RadAjaxManager1");

ajaxManager.AjaxSettings.AddAjaxSetting(

this.FindControl("grvUserLogs"), this);         
}



The result,...(when i run it)  having inserted a row into the grid,...It Fires the LoadUserCtl on the BaseMain MngrForm,
which then tries to load the Uctl (which's grid is supposed to update, ) into the ContentPane of the Manager form, ..(It currently holds the Tabbed UCtl and should continue to do so.)

?? How / What do I set/do (on Ajax Mngr?) to prevent this, and just refresh my grid in the UCtl loaded into the Tab of the TabbedUctl without trying to get the Mngr to load it in place of the TabbedUctl????
STUMPED !! help

TIA
Neal

ie Mngr Form ->TabbedUCtl -->UCtl(+Grid,ajaxified dynamically)
and fires on Mngr to Load UCtl(Grid) to load/replace Tabbed UCtl.

The Mngr form has RadAjaxNManager included in HTML

aspx is as follows

<

body>

<form id="form1" runat="server">

<div id="FormDiv" style="width:100%; height:100%; border:solid ,1,gray">

<radA:RadAjaxManager ID="RadAjaxManager1" runat="server" >

<AjaxSettings>

<radA:AjaxSetting AjaxControlID="RadMenu1">

<UpdatedControls>

<radA:AjaxUpdatedControl ControlID="TopContentPanel" />

</UpdatedControls>

</radA:AjaxSetting>

<radA:AjaxSetting AjaxControlID="Radmenu2">

<UpdatedControls>

<radA:AjaxUpdatedControl ControlID="BottomContentPanel" />

</UpdatedControls>

</radA:AjaxSetting>

</AjaxSettings>

</radA:RadAjaxManager>

<asp:Panel

ID="TopNavPanel"

runat="server"

CssClass="TopNavPanel"

ScrollBars="Auto">

<radp:RadPanelbar ID="RadPanelbar1" runat="server" Width="190px"

Skin="Outlook" height="100%" >

<Items>

<radp:RadPanelItem Text="DM Admin" runat="server"

Expanded="true" Width="100%" BorderStyle="none">

<Items>

<radp:RadPanelItem runat="server" >

<ItemTemplate>

<radm:RadMenu ID="RadMenu1"

runat="server"

Flow="Vertical" Width="100%" Height="100%"

>

<Items>

<radm:RadMenuItem ID="TabbedUCtl"

runat="server"

BackColor="#404040" ForeColor="Silver"

Text="TabbedUCtl"

Width="100%" >

<GroupSettings ExpandDirection="Down"

Width="90px" />

</radm:RadMenuItem>

the CodeBehind is basic,..uses properties for SelectedUCtl as per most of the Telerik Examples..

Control Load ,CtlReload and 

RadAjaxManager1_ResolveUpdatedControls


The menu items click load the required userctl into the required ContentPane via the ReloadSelectedUctl property and the ReloadUserCtl() function.

protected void Page_Load(object sender, EventArgs e)

{

//Recreacte the user control for each page-lifecycle since we are adding it dynamically to the page

LoadUserControl(

this.selectedUC);

}

public void LoadUserControl(string userControl)

{

//Load user control onto page

Control selectedUserControl = Page.LoadControl(userControl);

//Generate an Unique ID based the control path

string uniqueID = this.selectedUC.Split('.')[0];

uniqueID = uniqueID.Replace(

"/", "").Replace("~", "");

selectedUserControl.ID = uniqueID;

//Load control into Required Panel

//...and prevent controls from being loaded twice..weird error,..??

if (TopContentPanel.FindControl(selectedUserControl.ID) == null)

{

TopContentPanel.Controls.Add(selectedUserControl);

}

}

public void ReloadUserControl()

{

//Loads the UCtl from the Property,...usually set from the UCtl..hence Public property

TopContentPanel.Controls.Clear();

LoadUserControl(

this.selectedUC);

}


    



3 Answers, 1 is accepted

Sort by
0
plamen
Top achievements
Rank 1
answered on 30 May 2008, 11:07 AM
Hi Neal,


You can review the following topic and online example on the matter:


Hope this helps.
<John:Peel />
0
Neal
Top achievements
Rank 1
answered on 30 May 2008, 01:16 PM
Thanks John,

That would do it,...however I have version Q4 2006.
So while the company are ordering the latest release,..

If I were to load this paricular UCtl as an aspx page instead  and set it's target as the pane I require, (with some logic as to loading/unloading that vs UCtls still loadable into the same pane... the main parent page loads into top and bottom content panes from one of 3 left side Nav menus),... would I not be able to Ajaxify that aspx (its grid and timer) then? and that without without interfering with the MainForms AjaxManager??

rgds
Neal

0
plamen
Top achievements
Rank 1
answered on 02 Jun 2008, 10:55 AM
hi: )

Dynamic loading of user controls with AJAX for asp.net is also discussed in the following online help resource:


RadAjax help -> How-To -> Loading User Controls with AJAX


Thanks...
<John:Peel />
Tags
Ajax
Asked by
Neal
Top achievements
Rank 1
Answers by
plamen
Top achievements
Rank 1
Neal
Top achievements
Rank 1
Share this question
or