Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 14th, 2006, 11:14 PM
Registered User
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form email Questions

I am trying to do my first ASP webpage and it is a form to fill out and email the results. I am having trouble with the message text (BTW I am doing this in Dreamweaver if that matters). Anyway I am trying to do two things.

1. Below is my message text. I would like each of the elements to fall on different lines in the email, that is name on line 1, address on line 2 etc. Anyway, I cannot get line breaks to work in here to save my life. Everytime I change something I get a new error. For example with the below code I get a CS1002 error which I think means it is looking for a semi colon. Of course there are no line breaks in the code below because they don't work....I just don't get it.

message.Body = "Name: " + txtName.Text + "Address: " + txtAddress.Text + "City, State Zip: " + txtCity.Text + ", " + txtState.Text + " " + txtZip.Text + "Phone: " + txtPhone.Text + "email: " + txtEmail.Text + "Message: " txtMessage.Text;

2. After they hit submit I would also like a pdf to open up in another window. How do I do that?

John C Toennies
Old September 15th, 2006, 06:23 AM
Authorized User
Join Date: Sep 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts

HI John, You are trying to do the same using ASP (VB Script right) or is that code given below in Javascript. If you are using VB SCript then you need to use & instead of + and there is no need for the semicolon at the end.

If its is not working to help you in debugging, dont use all the fields, try with a field or two only and see if the error persits, and then try adding the rest of the fields.

As for opening a pdf window, you can use response.redirect("pdffile.pdf"). To open in a new window, i am not sure, but will check and post it here.

Vincent Thomas
Old September 15th, 2006, 07:09 AM
Registered User
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to simonwilbert Send a message via Yahoo to simonwilbert

you are missing a + right at the end of the statement....:D

should be
     ...Message: " + txtMessage.Text;

Simon Hurley
Old September 15th, 2006, 07:54 AM
Registered User
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks, I hav tried this with just two fields and all of them and it is driving me nuts! G<> Any thoughts on a line feed so it looks better in the email? Also, thoughts about opening up the pdf in a new window and maybe redirecting to a different page?

John C Toennies
Old September 15th, 2006, 10:58 AM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

First the line breaks:

Is your message format HTML or Text? For text you should use: "\r\n"; to give you a carriage return and a line feed and if its HTML use the <br> tag. (If you have tried using "\r\n"; I am not quite sure why it isnt working as I have this implemented in one of my applications and it works fine.)

For the pdf window, just send a javascript window.open() command to the browser and spawn a new window that loads your pdf.


--Stole this from a moderator

I will only tell you how to do it, not do it for you.

Unless, of course, you want to hire me to do work for you.

Similar Threads
Thread Thread Starter Forum Replies Last Post
form with conditional questions jcrowley PHP How-To 0 January 30th, 2007 12:02 AM
Access Form Questions sario777 Access 2 April 12th, 2005 06:38 PM
Javascript Form Questions The_Jackal Javascript How-To 0 August 24th, 2004 12:50 PM
First normal form and attachement questions?? wasaan SQL Server 2000 2 July 17th, 2003 09:43 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.