Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 2nd, 2005, 07:52 PM
cgacfox cgacfox is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 cgacfox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 23 sec
Reputation Power: 0
Question trouble with code conversion

I am really new to asp and ASP.NET and have found a program on the Internet that converts Coldfusion code to ASP code. I am working on an information request form and the person is to fill out the form and submit it. Then another page will populate for them thanking them and letting them know their information has been sent. Here is the converted code for the response page:
<%
dim Mailbody
dim MailObj = Server.CreateObject("CDONTS.NewMail")
if IsObject(MailObj) then
MailObj.From = "Web""
MailObj.TO = "cgacfox@comcast.net"
MailObj.BodyFormat = "0"
MailObj.Subject = "Req Information"
MailObj.Body = "The suggestion information is:Name: <% response.write Request.Form("Name")%>
email: <% response.write Request.Form("email")%>URL: <% response.write Request.Form("URL")%>City
<% response.write Request.Form("City")%>Comments: <% response.write Request.Form("comments")%>"
MailObj.Send
Set MailObj = Nothing
End If
%>
<!-- You should check the MailObj.Body and be sure that it is workable. -->

When I test it here is what shows up in the browser:

Thank you

Your information has been sent!

We appreciate your business.

Thank you!

email: URL: City Comments: " MailObj.Send Set MailObj = Nothing End If %>


This bottom part should not be there. I don't know what is incorrect in the code because I do not know enough about ASP yet. Could someone take a look at this and see if they can see anything incorrect. Thanks.

Reply With Quote
  #2  
Old February 4th, 2005, 06:40 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,002 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 19 h 40 m 17 sec
Reputation Power: 105
This structure is a bit problematic:
Code:
<% response.write Request.Form("Name")%>
It's customary to just do it this way:
Code:
<%= Request.Form("Name") %>
The main problem with the code is that the <% ... %> script blocks have become entangled. Try this:
Code:
<%
 	dim Mailbody
 	dim MailObj = Server.CreateObject("CDONTS.NewMail")
 	if IsObject(MailObj) then
 		MailObj.From = "Web""
 		MailObj.TO = "cgacfox@comcast.net"
 		MailObj.BodyFormat = "0"
 		MailObj.Subject = "Req Information"
 		MailObj.Body =    "The suggestion information is:Name: " & Request.Form("Name") & vbcrlf & _
 		    			"email: " & Request.Form("email") & vbcrlf & _
 		    			"URL: " & Request.Form("URL") & vbcrlf & _
 		    			"City: " & Request.Form("City") & vbcrlf & _
 		    			"Comments: " & Request.Form("comments")
 		MailObj.Send
 	End If
 	Set MailObj = Nothing
 %>
__________________
selwonk

If I've posted some code above, you might think it looks a bit simplistic. It might be. I'd rather people tried the next step themselves rather than getting a full solution on a plate. That way they learn more!

Reply With Quote
  #3  
Old February 4th, 2005, 02:04 PM
cgacfox cgacfox is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 cgacfox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 23 sec
Reputation Power: 0
trouble with code conversion

Thanks for your response. I tried this but the name from the html page is not populating. Also, because I am so new to using ASP, could you break it down for me and explain what the different parts of the code are doing so I have a better understanding? I would really appreciate it. Thanks.


Quote:
Originally Posted by selwonk
This structure is a bit problematic:
Code:
<% response.write Request.Form("Name")%>
It's customary to just do it this way:
Code:
<%= Request.Form("Name") %>
The main problem with the code is that the <% ... %> script blocks have become entangled. Try this:
Code:
<%
	dim Mailbody
	dim MailObj = Server.CreateObject("CDONTS.NewMail")
	if IsObject(MailObj) then
		MailObj.From = "Web""
		MailObj.TO = "cgacfox@comcast.net"
		MailObj.BodyFormat = "0"
		MailObj.Subject = "Req Information"
		MailObj.Body = "The suggestion information is:Name: " & Request.Form("Name") & vbcrlf & _
					 "email: " & Request.Form("email") & vbcrlf & _
					 "URL: " & Request.Form("URL") & vbcrlf & _
					 "City: " & Request.Form("City") & vbcrlf & _
					 "Comments: " & Request.Form("comments")
		MailObj.Send
	End If
	Set MailObj = Nothing
%>

Reply With Quote
  #4  
Old February 4th, 2005, 02:11 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,002 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 19 h 40 m 17 sec
Reputation Power: 105
Ok...

1. Request.Form() request the value of a form field. If the method in your FORM tag is GET, you should use Request.QueryString()

2. The & character is used to concatenate to string values. The use of & _ is simply used to wrap across multiple lines

3. Response.Write() is used to display a message in the browser. You can also embed the value of a variable in your browser display using <%= str_Variable %> which is equivelant to <% Response.Write(str_Variable) %>

4. If your field does not get populated, try checking that the field in your FORM definately matches the name of the field you are requesting with Request.Form()

5. vbcrlf is the Visual Basic equivelant of a carriage/line feed pair. Used in the .Body line, this puts a hard return at the end of each line

Is there anything else specific you would like to know?

Reply With Quote
  #5  
Old February 4th, 2005, 03:00 PM
cgacfox cgacfox is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 cgacfox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 23 sec
Reputation Power: 0
Why are there 3 sets of quotes?
MailObj.From = "Web""

I am working in Dreamweaver MX 2004 and the colors are confusing me.


Thank you <%= Request.Form("Name") %>

MailObj.Body = "The req information is:Name: " & Request.Form("Name") & vbcrlf & _

The green shows ASP Include Attribute Value, the pink shows ASP Include Attributes, and the blue shows VBScript Reserved Keywords. The first line has the "Request.Form as an include and in the second line it is an include attribute value. I have not worked with VB in a couple of years and that was a class that I took in college as part of my BSIT degree. If you don't use this stuff frequently after learning it, you tend to forget. If you are wondering about this, I am a 45 year old female that is drastically changing careers! I may be getting too specific but I just want to make sure that I am understanding what the code is doing. I do have a couple of books that I purchased for ASP and ASP.NET but I have not really sat down with them yet. If I am driving you nuts, I am sorry. I just want to learn!

The rest of the code that you sent me does not have a color associated with the request form names.

"email: " & Request.Form("email") & vbcrlf & _
"City: " & Request.Form("City") & vbcrlf & _
"Comments: " & Request.Form("comments")


Thanks again for you patience with me.

Reply With Quote
  #6  
Old February 5th, 2005, 07:42 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,002 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 19 h 40 m 17 sec
Reputation Power: 105
Quotes should normally be single:

<% str_Variable = "Value" %>

However, double quotes are used within quotes:

<% str_Value = "<a href=""thispage.asp"" target=""_blank"">"

I'd strongly recommend a different editor if you are reliant on the syntax colouring. I'd recommend Editplus:

http://www.editplus.com

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > trouble with code conversion


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT