Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need two results from one action

Status
Not open for further replies.

JGresko

Programmer
Apr 24, 2002
86
US
This is what I'm trying to do...

1) Button clicked on original page
2) Use ASP to checks status of requested document
3) If document is available
- Use ASP to update access log
- Display document status info in original window
AND
Begin download of requested document (.doc or .xls)

OR
If document is not available only display
document status info in original window

It's the AND part that's causing me the problem... Each action by itself if simple, but I'm having trouble coordinating both at the same time.

 
run each part in a sub routine

use some if then statements to call the subs

check if document available
if document available then
call show_form
call begin_download
else
call show_form
end if

sub show_form()

end sub

sub begin_download(

end sub
Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
The only way I can think to begin the download is via a response.redirect, but I can't call that twice...

OR

writing a JavaScript window.open("URLofDoc") in the original doc if a session variable is true... but then I'll have an extra window hanging out there...


so both ideas are flawed... anyone have another idea?
 
Drop all of the html for the display (first part of AND) into a function in the file that is checking what to do. When you hit the first case, you call the function to display that page to the screen. You can then send the actual data. You may want to look into setting the response header, you could create a file that accepts a filename in the querystring, sets the header, than binary writes the file to the output stream. Then in your function that does the display, window.open it.

Downloadable Sample:

-Tarwn ------------ My Little Dictionary ---------
Extreme Programming - (1)Trying to code before my second cup of coffee. (2) While(1){ Ctrl+C; Ctrl+V; }
FAQ - Web-ese for "Forget Asking Questions, I am to busy" :p
 
Thanks Tarwn

That's got the download working and the logic in the page that processes it, but for some reason the original page doesn't refresh to show the updated status info... only a small qlitch since the actions do complete correctly. I'm sure I'll be able to correct it.
 

Ok, I spoke too soon [spineyes]

If I refresh in the JavaScript, it cancles the download

If I refresh in the ASP, the download cancles the refresh


... how did you time it?
 
you shouldn't need to actually refresh your page, you could just have a span on it somewhere with an id like so:

Code:
<html>
.
.
.
<body>
.
.
.
<span id=&quot;statusMsg&quot;></span>
.
.
.
Then add a javascript function to change the innerHTML of the span to display the status before you direct them to the page with the download.

It may be safer to actually window.open (javascript) a new window with the address of the download script in it so your original window will still be active. Then you could refresh all you wanted. This is similar to how places like CNet do their download files.
-Tarwn ------------ My Little Dictionary ---------
Extreme Programming - (1)Trying to code before my second cup of coffee. (2) While(1){ Ctrl+C; Ctrl+V; }
Corrections - Comments made out of a desire to be helpful and repay the millions given to me :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top