Connecting Tech Pros Worldwide Help | Site Map

how do I stop server from running when I want to cancel out?

BeemerBiker's Avatar
Member
 
Join Date: Jul 2008
Location: San Antonio, Texas
Posts: 68
#1: Sep 27 '09
I am using CancelAsyncPostback in an attempt to stop a page from loading. It actually works (the page wont get a postback) but the server keeps running, processing data I dont want processed until it gets done with a task I really didnt want done because I didnt realize how long it took

I tried adding a button to do a server transfer to "./Default.aspx" but it only transfered AFTER the processing was complete.

what I tried that didnt work like I thought it would

Expand|Select|Wrap|Line Numbers
  1. var prm = Sys.WebForms.PageRequestManager.getInstance();
  2.         function CancelAsyncPostBack() {
  3.             if (prm.get_isInAsyncPostBack()) {
  4.                 prm.abortPostBack();
  5.                 return false;
  6.             }
  7.         }
  8. ---etc---
  9.         function EndRequest(sender, args) {
  10.             var err = args.get_error();
  11.             if (err != null && err.name === 'Sys.WebForms.PageRequestManagerTimeoutException') {
  12.                 args.set_errorHandled(true);
  13.                 location.reload(true);
  14.                 return;
  15.             }
  16.             if (postBackElement.id == 'Panel1Trigger') {
  17.                 $get('UpdateProgress1').style.display = 'none';
  18.             }
  19.         }
  20. ---etc--
  21.             <ProgressTemplate>
  22.                 Processing...
  23.                 <input id="Button2" 
  24.                        type="button" 
  25.                        value="cancel" 
  26.                        onclick="CancelAsyncPostBack()"; />
  27.             </ProgressTemplate>
  28.  
When I click on the cancel button the CancelAsync runs and then falls thru to the EndRequest. This does not actually stop the server from running. Surely there is some command I can use to signal to the server to exit the loop it is in?

Is there anything my C# web app can call to determine if the user ran that CancelAsync process?

Thanks for looking.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#2: Sep 28 '09

re: how do I stop server from running when I want to cancel out?


Sorry but there is no such command.

The CancelAsyncPostback is meant for just cancelling an Ajax Request from occurring...it isn't meant to cancel a request that has already been sent to the server.

There is no way that I know of that will cancel the server side process once it's going. Each individual request is a separate request...and therefore there is no "interrupting" or "stopping" a request that is being processed.
Reply