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

ajaxRequestWithTarget causing postback

1 Answer 205 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Suraj
Top achievements
Rank 1
Suraj asked on 10 Nov 2011, 07:08 AM
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. 

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 14 Nov 2011, 10:43 AM
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
Tags
Ajax
Asked by
Suraj
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or