Showing posts with label handling. Show all posts
Showing posts with label handling. Show all posts

Monday, March 26, 2012

PageRequestManager only processes one asynch callback at a time?

I was under the impression that the asp.net ajax framework was capable of handling multiple asynch callbacks simultaneously and processing the results of each in the order that they come back. However, I accidentally discovered something interesting: it seems that if you begin an asynch callback from the browser while a previous asynch callback is still in process, the first one gets cancelled by the client-side PageRequestManager instance before it begins the second one.

To see what I'm talking about, you can go to this official MS ajax example:http://ajax.asp.net/docs/Samples/System.Web.UI.UpdateProgress1/cs/Default.aspx

Try clicking the first button, then quickly clicking the second button before the first date gets updated on the page. Notice that after a few seconds, the second date changes as a result of the second asynch callback, but the first date never gets updated. This is because the asp.net ajax framework is prematurely ending the first request as soon as you initiate the second request by clicking the second button.

I'm working on a project with multiple UpdatePanels on a page that do completely separate things in their server-side code, and ideally we would like the user to be able to initiate a callback in one panel and then immediately initiate a callback in the second panel, and have both of the asynchronous callbacks processing at the same time. At the moment, it doesn't seem like this is a possibility in the asp.net ajax framework.

If anybody can tell me how I might be able to get around this issue I would be very appreciative.

hello.

well, what you ask isn't doable with the current code of the platform. you can only have more than one remote call if you're using web services (and even in these cases you might face some problems which have been described here: http://www.codeproject.com/Ajax/aspnetajaxtips.asp)

Wednesday, March 21, 2012

Partial Page Post Backs - Am I doing this right?

Hi,

This may seem pretty basic, but I'm teaching myself AJAX and I have a question about handling partial page post backs.

I have a page with three update panels. Each is triggered by a different event (two use drop down lists, one uses a radio button group). In my page load event, I first check 'ScriptManager1.IsInAsyncPostBack' to see if I have an AJAX post back. Then I check the value of 'ScriptManager1.AsyncPostBackSourceElementID' to determine which control created the post back. That result determines which block of code my program runs.

Is this the correct way to code a page with multiple partial page post backs? It makes sense to me, but I'd like to know that I am using the correct procedure.

Thanks for your help!

That's one way to do it, and will generally work.

You might consider something more directly event driven though, to make it easier to write/maintain. You can set those dropdowns to AutoPostBack and then handle their OnSelectedIndexChanged event the same way you normally would in a non-AJAX situation. This has the added benefit of degrading gracefully back to regular postbacks when AJAX isn't available on the client, which is a good thing to always keep in mind.