ajaxRequestWithTarget causing postback

2 posts, 0 answers
  1. Suraj
    Suraj avatar
    12 posts
    Member since:
    Oct 2011

    Posted 10 Nov 2011 Link to this post

    Hi,

    I have a page which has nested master.Uppermost master has RadAjaxManager in it.

    In this page I m executing following code on onclick event of div

    $find("<%=RadAjaxManager.GetCurrent(Page).ClientID%>").ajaxRequestWithTarget("__Page", "ClickSendInvites")

    And in code behind file I have following code

    RadAjaxManager AjaxManager = RadAjaxManager.GetCurrent(Page);
     
               AjaxManager.AjaxSettings.AddAjaxSetting(Panel1, Panel1, RadAjaxLoadingPanel1);
               AjaxManager.AjaxSettings.AddAjaxSetting(AjaxManager, Panel1, RadAjaxLoadingPanel1);

    Above mentioned div is in Panel1.

    When I click on the div.it is causing postback.

    Regards,
    Suraj Patil. 
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 14 Nov 2011 Link to this post

    Hello Suraj,

    Modify your code as below and handle the request in the RadAjaxManager AjaxRequest event then:
    $find("<%=RadAjaxManager.GetCurrent(Page).ClientID%>").ajaxRequest("ClickSendInvites");
    RadAjaxManager AjaxManager = RadAjaxManager.GetCurrent(Page);
    AjaxManager.AjaxSettings.AddAjaxSetting(Panel1, Panel1, RadAjaxLoadingPanel1);
    AjaxManager.AjaxSettings.AddAjaxSetting(AjaxManager, Panel1, RadAjaxLoadingPanel1);
    AjaxManager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(AjaxManager_AjaxRequest);
    void AjaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "ClickSendInvites")
        {
            //your code here
        }
    }

    Note that in order to use the ajaxRequestWithTarget() method, you should pass it the UniqueID of a valid postback control, like an ASP:Button for instance.

    Kind regards,
    Iana Tsolova
    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
Back to Top