Link to home
Start Free TrialLog in
Avatar of Wubbie
Wubbie

asked on

"Please Wait" page while ASP is performing tasks in background

We are firing off a DTS package when the user clicks on a button on our page (this part works properly).  This DTS package
will set a value in a parameter table to indicate that it is finished running.  It takes about 2-3 minutes to execute.

In the meantime, we want the user to be redirected to a page that says "Please wait..." and in the background of that page, have the ASP script looping through to check the value in the table that the DTS package sets.  It checks it, then pauses for about 10 seconds, and loops until it finds a successful run or until it reaches 30 attempts.  If it reaches the 30 attempts, it will redirect them to a page that indictates a timeout.

The problem is that when they click the button to fire off the DTS package, the DTS package gets started just fine and then it's supposed to redirect them to the "Please wait" page.  However, the script starts doing its loop with the pauses so the browser just sits there waiting for the page to load without displaying the please wait.

I am using classic ASP w/SQL Server 2000 and I have heard that you can do threads somehow (with components?)  Does anyone have more information about this or another way to accomplish this.  I have seen this kind of thing done on other sites.  We're flexible and can do the DTS checking a different way, too.  

(Sorry it's only 125 pts, it's all I have)
Avatar of enforge
enforge

The easiest way to do it is to:

On your page that launches the process, add some JavaScript that will show a wait screen when they click. Like such:


<head>

<script language="javascript">

  function showWait()
  {
    divMain.style.display = 'none';
    divWat.style.display = '';
    window.location = 'urlthatrunsthepackage.asp';
  }

</script>

</head>

<body>

<div id="divMain">

  Normal Page Content Here (to launch process)

  <a href="javascript:showWait()">Click Here to Run Process!</a>

</div>

<div id="divWait" style="display:none">

   Please Wait ....

</div>

</body>

Now, that is a quick shortcut to get this done. You can embed the HTML for your entire page in the divMain object, and the alternative HTML for the wait layer in the divWait object.

If you want to get into asynchronous threading, you can do that too, but only if you really need it.
ASKER CERTIFIED SOLUTION
Avatar of Silverbug
Silverbug

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wubbie

ASKER

Silverbug, that worked!  I am actually using an include so that I don't leave the ASP page, but Response.Flush did take care of it.

However, now I'm having the problem where I need to redirect them to the success page but I've already sent my HTML "Please Wait" page so I can't use Response.Redirect or Server.Transfer.

Know of another way to do that?
Avatar of Wubbie

ASKER

Thanks Silverbug, we've got it working now by opening another window.  The flush helped!
np, glad to help