views:

20

answers:

1

I've been coerced into applying Microsoft's PageAsyncTask objects, which I am new to (before I've always used jQuery AJAX calls). I've got everything working just right except once the work is done and the endHandler is called, how do I have the calling page update its contents?

Basically my async function runs a slew of database operations and reports back to the caller with HTML regarding the results of the database run. I'd like to display these results on the calling page once the operation has completed. I have everything working except the calling page displaying the results.

Your help is appreciated.

+1  A: 

Using RegisterAsyncTask makes the asp.net page lifecycle asynchronous, but from the browser's perspective, the HttpRequest is still synchronous. Essentially, when you use AsyncTasks in your asp.net page, it behaves exactly as any other asp.net page, except that during those async operations, the thread is returned to IIS so it can be used by other requests.

Therefore, your async operation shouldn't necessarily return HTML, because its caller isn't the browser; you're still within the lifecycle of the original asp.net page call. I believe your async callback can apply the DB results directly to the various controls on the page, same as you would if you hadn't implemented the operation asynchronously.

mikemanne
Ah, I understand. I've proven just what you said a few moments ago. My new intention is to turn the work method into a webmethod and call it that way; fire and forget. The work method will populate a designated Session object to report its progress and status. I will use a WARP control to poll that object from the calling page and display to the user what is going on. Do you anticipate that working out for me?
Honus Wagner
Sounds to me like that should work well. Except for the poll-for-status updates part, it's the same approach that I'm using on a current project. The one caveat I'm aware of is that the webmethod will tie up a worker thread for its duration. I haven't been able to find a way around that yet (see my current stackoverflow question: http://stackoverflow.com/questions/3322599/asmx-equivalent-of-registerasynctask)
mikemanne