Saturday, March 24, 2012

Abort AJAX Postback

Hello,

I am developing a project, which has many things on admin and merchant side, but very less on user site.

The user site contains a page from where user can search the data. This is the main page on user site.

The search page contains 10 sliders and 6 different parameters which are checkboxlist. There are at least 5, 00,000 records in the database.

I am using database paging to get result fast.

I am using AJAX on this page.

Now the problem is that when ever I move the slider and release it then button click event is called from JavaScript.

I have 10 sliders on the page now when I move all the sliders one by one the page becomes very slow. It performs all the post backs in the queue.

Is there any way from which I can cancel the previous post back if the page is already inasynchronous postback.

I have even tried the following code when the user moves the slider; I call the following function;

function StopPostBack()

{

var CheckPostBack = Sys.WebForms.PageRequestManager.getInstance();

if (CheckPostBack.get_isInAsyncPostBack())

{

CheckPostBack.abortPostBack();

}

}

But this too not helped me much.

I think the problem is that when ever user moves the first slider and release it the button click event is called and in that the stored procedure is called to fetch the data.

Now when user move another slider the function StopPostBack is called but till that time the application has started the database operation.

My stored procedure taking less then 2 sec to return the data. But when there are multiple movements of the slider the page is very slow.

How can I make is fast.

Regards,

Deepesh Verma

Hi Deepesh,

Please refer to this thread, http://forums.asp.net/thread/1695055.aspx
There is no easy way to abort the execution on the server from the client.
I think you need to find a way to reduce the occurrence of postback on the client.

No comments:

Post a Comment