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

[Solved] Help With User Control

5 Answers 262 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Mick
Top achievements
Rank 1
Mick asked on 02 May 2008, 10:24 AM
Hello,

I wrote a usercontrol some time ago which opened a URL within a RadWindow.
I needed to return some values from that window to the parent page, so I used the online examples using a RadAjaxManager. And all worked fine.

However the situation has now arrisen where I need more than one of these usercontrols on a page at anyone time. So I would like to start using the RadAjaxManagerProxy in my control rather than an actual manager.

The problem I am having, is within the usercontrol, I have the following javascript:

function

refreshAddress(arg)

{

if(!arg)

{

$find(

"<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");

}

else

{

$find(

"<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");

}

}

This doesnt seem to work, if I just switch the ID to the RadAjaxManagerProxys client ID.

5 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 02 May 2008, 10:31 AM
Hello Mick,

You need to get the RadAjaxManager client object instead of the proxy. You can use the GetCurrent() static method as explained in the docs here:

RadAjax and WebUserControls

Kind regards,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mick
Top achievements
Rank 1
answered on 02 May 2008, 10:55 AM
Im still unsure about how to do it in my scenario. I have created the simplest test project that illustrates my case, basically, the usercontrol opens a radwindow, within the radwindow the user sets a Session value (and the radwindow closes), the session value is then read into a property of the user control, which is then available to the calling page. Ajaxified by an UpdatePanel.

I just need to be able to do it with a RadAjaxManagerProxy rather than a radajaxmanager.

The test project is available for download here: http://www.mick-walker.co.uk/TestProject.zip

I would be grateful for any help.
0
Konstantin Petkov
Telerik team
answered on 06 May 2008, 09:11 AM
Hi Mick,

Basically all you need is the RadAjaxManager placed in the main page and configured as necessary:

            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="Panel1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager> 
            <asp:Panel ID="Panel1" runat="server"
                <uc1:uc_TestControl ID="Uc_TestControl1" runat="server" /> 
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
            </asp:Panel> 

so that it can update the label control:

    protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e) 
    { 
        switch (e.Argument.Split('?')[0]) 
        { 
            case "Rebind"
                Value = Session["Value"].ToString(); 
                break
 
        } 
 
        Label1.Text = Value.ToString(); 
    } 

You don't need the proxy control since it is provided for design-time purposes only. It does not have a client-side object as well as functions you would like to use. Instead, get the manager instance as below and call its ajaxRequest as you did before:

            function refreshAddress(arg) 
            { 
                if(!arg) 
                { 
                    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Rebind");                  
                } 
                else 
                { 
                    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RebindAndNavigate");                   
                } 
            } 


All the best,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mick
Top achievements
Rank 1
answered on 06 May 2008, 11:00 AM
Thank you for your reply.
I still see a major issue with the concept you suggested, in that the AjaxRequest function will not know which usercontrol initiated the request, if multiple instances of this control are present on the web form.

0
Konstantin Petkov
Telerik team
answered on 09 May 2008, 08:24 AM
Hello Mick,

I think there is solution in this case as well. The function I added at the bottom of my previous post resides within a user control. For each instance you can send as ajaxRequest argument the ID of the respective user control and determine which is the initiator at the code-behind.

All the best,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
Mick
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Mick
Top achievements
Rank 1
Share this question
or