RadAjaxManager with multiple user control ajax request handlers?

3 posts, 0 answers
  1. Jay
    Jay avatar
    59 posts
    Member since:
    Dec 2011

    Posted 20 Oct Link to this post

    So, I have a page with multiple user controls. There is a RadAjaxManager on the page. Each user control needs to make ajaxRequests from javascript, and I would like each control to handle that itself. Is this possible?

    So, for instance, I have control1 with the following in its code behind:

    protected void Page_Load(object sender, System.EventArgs e)
    {
        RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
        manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(Control1_AjaxRequest);
    }

    and control2 with

    protected void Page_Load(object sender, System.EventArgs e)
    {
        RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
        manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(Control2_AjaxRequest);
    }

    and in javascript, control1 does

    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest(dataString);

    and I end up in Control2_AjaxRequest rather than Control1_AjaxRequest.

    Is what I'm trying to do possible? If so, how? I'm currently trying to do this by adding a RadAjaxPanel to each control and invoking ajaxRequest on it, but I'm running into some code block issues with this that weren't there with RadAjaxManager.

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 25 Oct Link to this post

    Hello Jay,

    When using RadAjaxManager you should have only one control on the highest hierarchy page. Usually this would be a MasterPage. Then, you can handle the AjaxRequest event for that control and implement specific logic depending on the passed arguments.

    The code snippet below outlines the approach:


    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "control1_request")
        {
            // handle request from control 1
        }
        else if (e.Argument == "control2_request")
        {
            // handle request from control 2
        }
    }



    For additional information on using AjaxManager with UserControls please refer to the following articles.




    Regards,
    Viktor Tachev
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jay
    Jay avatar
    59 posts
    Member since:
    Dec 2011

    Posted 25 Oct in reply to Viktor Tachev Link to this post

    Thanks, Viktor. That's the approach I ended up with too, I was just wondering if there was something I was overlooking.
Back to Top