Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts

    Delaying response.redirect?

    I've set up an asp page that sends an email from the server after the user enters thier comments/name/email into a form. Everything with the CDO Mail works great, the problem comes in when I want to display a message saying thier email was successfully sent. I'd like this page to redirect back to the contact page after a period of ~5 seconds or so. This is the code I currently have:
    <%
    strName = session("Name")
    Response.Write strName & ",<br>"
    Response.Write "Your message has been successfully sent."
    Response.Redirect("contact.asp")
    %>

    It redirects immediately, and I'm not sure how to delay it so the user actually has time to see a verification for thier message.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    Response.Redirecting is only possible if nothing is sent to the client before the command. So you probably have the Response.Buffer set to True. What you can do is output the message and apply the meta tag for redirecting in your messagepage:

    <meta http-equiv="Refresh" content="5;url=contact.asp">
    I am the luckiest man in the world

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts
    doesnt the meta tag require me to have <html><head></head><html> tags at minimum on the page? The page is pure asp and has no previewable code so to speak. heres the entire page:
    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
    DIM strEmail, strName, strComments, mail, reply, objMail
    strEmail = session("Email")
    strName = session("Name")
    strComments = session("Comment")
    
    mail = "comments@kaji82.com"
    reply = session("Email")
    Set objMail = Server.CreateObject("CDONTS.NewMail")
    objMail.From = reply
    objMail.Subject = "New Message From " & strName
    objMail.To = mail
    objMail.Body = "Email: " & strEmail & vbCrLf & _
    "Name: " & strName & vbCrLf & _
    "Comments: " & vbCrLf & strComments
    
    objMail.Send
    Set objMail = nothing
    %>
    
    <P>
    <%
    strName = session("Name")
    Response.Write strName & ",<br>"
    Response.Write "Your message has been successfully sent." 
    Response.Redirect("contact.asp")
    %>,</P>
    
    <%
    	session.Abandon()
    %>
    Now, what do I need to add to make it display for a few seconds so the user can see that thier message has been sent successfully??

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    you're sending information to a browser, so it is always good practice to send a well formed html document. Including the <html> etc. tags.
    I am the luckiest man in the world

  • #5
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use
    Code:
    Response.AddHeader "Refresh", "5;URL=contact.asp"

  • #6
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by degsy
    You can use
    Code:
    Response.AddHeader "Refresh", "5;URL=contact.asp"
    Ah, ty. I knew there had to be a way with out adding in all the uneccessary HTML code to the page. Thank you!

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    Yeah, right, unneccesary html code. like <html> etcetera, why do we need that anyway
    I am the luckiest man in the world

  • #8
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Roelf
    Yeah, right, unneccesary html code. like <html> etcetera, why do we need that anyway
    its not needed on a page that does nothing but process information from one page to another...the user never sees the processing...only a simple msg that says the process compeleted successfully. It would be an utter waste of my time to code in all the html neccessary to simply say "it worked!" and move on to another page...

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    Quote Originally Posted by DakotaChick
    its not needed on a page that does nothing but process information from one page to another...the user never sees the processing...only a simple msg that says the process compeleted successfully. It would be an utter waste of my time to code in all the html neccessary to simply say "it worked!" and move on to another page...
    Then why don't you create a good html template, with all neccessary elements in it. A doctype declaration, <html> tags, etcetera. All stuff that is needed to make sure your output is correctly formatted by the browser.
    Whenever creating a new asp-page, copy-past the stuff in and add your asp code to make it function the way you want it.
    You seem to care about some formatting at least, you "coded" the <P> tag in your output.
    Be compliant, it will save you time in the future
    I am the luckiest man in the world

  • #10
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Roelf
    Then why don't you create a good html template, with all neccessary elements in it. A doctype declaration, <html> tags, etcetera. All stuff that is needed to make sure your output is correctly formatted by the browser.
    Whenever creating a new asp-page, copy-past the stuff in and add your asp code to make it function the way you want it.
    You seem to care about some formatting at least, you "coded" the <P> tag in your output.
    Be compliant, it will save you time in the future
    every other page (over 85 other pages) is based off of 1 of 2 templates...that page simply sends an email containing the form data...no need for it to look pretty to just say "it worked."

    And the copy paste technique went out when dreamweaver and MS offered the option to "create from template."

    Instead of arguing with me over the right and wrong way to do things, why not just offer the answer to the question asked and keep the comments to your self? And in the case of not knowing the answer, saying nothing at all? What a novel idea...

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    My apologies if i offended you. Obviously you are right and i am wrong. I will keep comments to myself in the future
    I am the luckiest man in the world

  • #12
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you are outputting any data to the browser then it should be correctly formed.

    You never know what browser or OS / Device is being used to view your pages and maybe there is a strict browser out there that will refuse to display your page if there is no DOCTYPE, HEAD or BODY.

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    Quote Originally Posted by degsy
    If you are outputting any data to the browser then it should be correctly formed.

    You never know what browser or OS / Device is being used to view your pages and maybe there is a strict browser out there that will refuse to display your page if there is no DOCTYPE, HEAD or BODY.
    I agree completely, that is why i mentioned it. But DakotaChick seems to think of it in other ways
    I am the luckiest man in the world

  • #14
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts
    it was for testing phases more than actual use. there is a showif statement now on the contact page (which is a highly structured html/asp/vbscript page) that tells the user if everything went correctly. I just dont like all the extraneous coding during testing on my pc.

  • #15
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    As an aside, Response.Buffer is set to true by default beginning with IIS 5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •