| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
This structure is a bit problematic:
Code:
<% response.write Request.Form("Name")%>
Code:
<%= Request.Form("Name") %>
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! |
|
#3
|
|||
|
|||
|
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:
|
|
#4
|
||||
|
||||
|
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? |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
||||
|
||||
|
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 |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > trouble with code conversion |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|