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

[Solved] Ajax, master and controls loaded dynamically

1 Answer 118 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Yann
Top achievements
Rank 1
Yann asked on 08 Jun 2009, 03:22 PM
Hello,

Here is my trouble :

I've got a master page (called PODMaster.master) which contains RadAjaxManagerProxy and a contentplaceholder as described below :

        <form id="Form1" method="post" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
        <telerik:RadAjaxManager ID="AjaxManager1" runat="server" EnableAJAX=true>  
        </telerik:RadAjaxManager> 
        <telerik:RadWindowManager Behavior=None ReloadOnShow=true Modal=true InitialBehavior=None VisibleStatusbar=false VisibleTitlebar=false id="Singleton" Skin="Default" runat="server">  
        </telerik:RadWindowManager> 
        <div> 
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">  
            </asp:ContentPlaceHolder> 
        </div> 
    </form> 
 


Then, the application loads an ascx control (called wucPOD.ascx) which contains different html tables and a contentplaceholder :
<asp:PlaceHolder ID="ContenuPage" Runat="server"></asp:PlaceHolder> 

This ascx controls loads dynamically user controls called modules.
A module is an ascx control which contains a label, a placeholder for actions buttons, and a content placeholder.

For example, imagine that I've 2 controls loaded by wucPOD.ascx in my page : controlA and controlB.
The controlA contains a RadGrid 'GrilleRetards' and the RadGrid contains action button.
The controlB contains a RadGrid 'GrillePrets'.

So what I'd like to do is when I click on the button in the RadGrid of the controlA, the RadGrid in the controlB is updated, and the 2 controls are ajaxified, of course.

What could be the best approch to perform this ?

Note that I've already done that with a RadAjaxManagerProxy on controlA and controlB.
In the controlA, on load, i've added AjaxSetting like this :
        If Not IsNothing(SessionsProfil.getModule_Pret()) Then 
            AjaxManagerProxyRetards.AjaxSettings.AddAjaxSetting(GrilleRetards, SessionsProfil.getModule_Pret())  
        End If 
 

and on the command evenement :
                    If Not IsNothing(SessionsProfil.getModule_Pret()) Then 
                        SessionsProfil.getModule_Pret().Refresh()  
                    End If 
 

But as you see, i saved the module controlB in a session variable to allow refreshing it.
And I think it's not the best approach.

I supose that I need a RadAlaxManagerProxy on the main user control wucPOD, and register each ajaxsetting in child modules (for example controlA) but I'm not sure.
And more, some modules are not ajaxified and need redirections.
So could you please tell me how I could do that ?
Thanks for your answer
Yann

1 Answer, 1 is accepted

Sort by
0
Ockert
Top achievements
Rank 2
answered on 08 Jun 2009, 03:55 PM
Use event handlers in your controls.

this is how I whould have done it.
----------------------------------------------------
in controlA

public event EventHandler SomeEvent;
 protected void somebutton_Click(object sender, EventArgs e)
    {
               if(SomeEvent != null)
               SomeEvent(sender, e);
    }
----------------------------------------------------
in controlB


public void DoSomething(string what_ever)
{
//do something with what_ever
}
---------------------------------------------------------
in wucPOD.ascx

 protected void Page_Load(object sender, EventArgs e)
    {
        controlA_name.SomeEvent += new EventHandler(SomeEventhappend);

}

void SomeEventhappend(object sender, EventArgs e)
    {
          controlB_name.DoSomething("hello");
    }
-------------------------------------------------------------


put  <asp:PlaceHolder ID="ContenuPage" Runat="server"></asp:PlaceHolder> inside a RadAjaxPanel and don't use the ajaxmanager(It over complicates things)



Tags
Ajax
Asked by
Yann
Top achievements
Rank 1
Answers by
Ockert
Top achievements
Rank 2
Share this question
or