If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > how to arrange between response.write & response.redirect

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-12-04, 21:13
ayu ayu is offline
Registered User
 
Join Date: Apr 2004
Location: Malaysia
Posts: 25
Thumbs down how to arrange between response.write & response.redirect

hi friends,

in my page, after I check the condition, I want to pop up a message and then go to next page. I'm using response.write and response.redirect. But only response.redirect done.

here is my coding

Response.Write "<script type='text/javascript'>alert('Terdapat permintaan untuk sokong/lulus cuti.');</script>"
Response.Redirect("masuk.asp")

please help....
Reply With Quote
  #2 (permalink)  
Old 05-12-04, 22:28
MrWizard MrWizard is offline
Registered User
 
Join Date: Mar 2003
Location: Atlanta, GA
Posts: 191
I don't know if this is the answer you're looking for, but you must remember that ASP is processed entirely on the server FIRST... and THEN the html is rendered and sent to the client's browser. This means that you cannot do things like "Alerts" in the middle of an ASP page..... it just doesn't work that way. You need to use something like JavaScript to do that.

Tim
__________________
Tim
Reply With Quote
  #3 (permalink)  
Old 05-13-04, 02:59
ayu ayu is offline
Registered User
 
Join Date: Apr 2004
Location: Malaysia
Posts: 25
Thank you for giving me an idea.
Reply With Quote
  #4 (permalink)  
Old 05-13-04, 10:37
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Ok.. you can't do both. Gotta do one or the other. Response.Redirect, if it's in fact doing the redirect (which would be interesting), can usually only be called BEFORE anything is written to the client's browser. Once header information is sent, there's no redirecting. Response.Redirect itself is the response to the browser (such as 200, 404, etc). By sending data to the browser before the response.redirect the browser has to first send a 200 (OK), and now you're stuck, because you can't then send another response to tell the browser to redirect.

So, now you may be wondering what you can do so solve your delema. Look up META refresh. You can force the browser to do a redirect for you, but I'm about to throw another wrench into the machine. While a JavaScript alert() box is active, the page will not redirect. So you'd have to combine the META refresh, with some javascript that pops open a new browser window with your error message.

Format of META refresh:
<META HTTP-EQUIV="refresh" CONTENT="#;URL=<path>">
# = number of seconds to refresh/redirect after
<path> = address you want to refresh/redirect the browser to
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On