Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP Script Opens New Window!

Reply
Thread Tools

ASP Script Opens New Window!

 
 
Robert Atkinson
Guest
Posts: n/a
 
      01-29-2004
I am quite new to ASP and trying to find my feet!

I've cobbled together some code to email some form data which works
fine, but when I try to write a success message back to the browser,
or use response.redirect, my browser opens a new window instead of
writing to the current window.

Is there something I can do to stop this? My code is pasted below.

Many thanks, Robert.


MAILFORM.HTM

<form method="POST" action="contactus.asp">
<table border="0" width="100%">
<tr>
<td width="24%">Your Name</td>
<td width="42%"><input type="text" name="Name" size="37"></td>
</tr>
<tr>
<td width="66%" valign="top" colspan="2">Message<br>
<textarea rows="4" name="Message" cols="52"></textarea></td>
</tr>
</table>
<table border="0" width="40%">
<tr>
<td width="33%" align="center"><input type="submit"
value="Send" name="B1"></td>
<td width="33%" align="center"><input type="reset"
value="Reset" name="B2"></td>
<td width="34%" align="center"><input type="button"
value="Cancel" name="B3" onclick='self.close()'></td>
</tr>
</table>
</form>



CONTACTUS.ASP

<%
smtp_server_address = "localhost"
on error resume next
response.buffer = true
Set Jmail = Server.CreateOBject( "JMail.Message" )
Jmail.Logging = true
Jmail.Silent = true
JMail.From = "C&NEE_Contact_Us"
Jmail.AddRecipient "(E-Mail Removed)"
JMail.Subject = "Information Request"
FOR EACH el IN Request.Form
body = body & el & ": " & Request.form(el) & vbcrlf
NEXT
JMail.Body = Body
JMail.Priority = 1
if not Jmail.Send(smtp_server_address) then
' There was an error - print the error log
Response.write ("Error:<br>" & Jmail.log)
else
' The message has been sent - redirect to confirmation page
Set JMail = Nothing
response.write ("<script>document.write('Your message has been
sent');</script>")
end if
Set JMail = Nothing
%>
 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-29-2004
why are you using a Response.Write to write a <script> with document.write?
Why not just use the Response.Write ?
Your problem isn't the Response.Write by the way, it's the client-side
<script> tag that's opening the new window

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


"Robert Atkinson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I am quite new to ASP and trying to find my feet!
>
> I've cobbled together some code to email some form data which works
> fine, but when I try to write a success message back to the browser,
> or use response.redirect, my browser opens a new window instead of
> writing to the current window.
>
> Is there something I can do to stop this? My code is pasted below.
>
> Many thanks, Robert.
>
>
> MAILFORM.HTM
>
> <form method="POST" action="contactus.asp">
> <table border="0" width="100%">
> <tr>
> <td width="24%">Your Name</td>
> <td width="42%"><input type="text" name="Name" size="37"></td>
> </tr>
> <tr>
> <td width="66%" valign="top" colspan="2">Message<br>
> <textarea rows="4" name="Message" cols="52"></textarea></td>
> </tr>
> </table>
> <table border="0" width="40%">
> <tr>
> <td width="33%" align="center"><input type="submit"
> value="Send" name="B1"></td>
> <td width="33%" align="center"><input type="reset"
> value="Reset" name="B2"></td>
> <td width="34%" align="center"><input type="button"
> value="Cancel" name="B3" onclick='self.close()'></td>
> </tr>
> </table>
> </form>
>
>
>
> CONTACTUS.ASP
>
> <%
> smtp_server_address = "localhost"
> on error resume next
> response.buffer = true
> Set Jmail = Server.CreateOBject( "JMail.Message" )
> Jmail.Logging = true
> Jmail.Silent = true
> JMail.From = "C&NEE_Contact_Us"
> Jmail.AddRecipient "(E-Mail Removed)"
> JMail.Subject = "Information Request"
> FOR EACH el IN Request.Form
> body = body & el & ": " & Request.form(el) & vbcrlf
> NEXT
> JMail.Body = Body
> JMail.Priority = 1
> if not Jmail.Send(smtp_server_address) then
> ' There was an error - print the error log
> Response.write ("Error:<br>" & Jmail.log)
> else
> ' The message has been sent - redirect to confirmation page
> Set JMail = Nothing
> response.write ("<script>document.write('Your message has been
> sent');</script>")
> end if
> Set JMail = Nothing
> %>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Script Debuggers opens without an error inside lambu76@gmail.com ASP General 0 03-15-2006 11:10 AM
URLs in location bar opens in new tabs ndavituri@gmail.com Firefox 4 11-27-2005 03:43 PM
asp:button that opens a new webpage? Roy ASP .Net 4 04-06-2005 06:41 PM
Firefox opens new browser when clicking links Bill Firefox 1 02-22-2005 04:28 PM
New PowerShot S1 IS opens new line for Canon Linda_N Digital Photography 0 02-09-2004 03:46 PM



Advertisments