My .asp page won't process asp code

We have a web site that is mostly static but has some flash stuff so there are some .asp pages but they aren't really doing anything dynamic.  Now I'm trying to add a form to be submitted to an employee's email but all the code I'm trying just doesn't work.  I've tried 4 different tutorials/walkthroughs explaining how to submit a form to an email address and none of the code works.

So I took a small piece of code and put it in my page and I kept getting errors referring to the syntax and one by one I adapted the code to the point that I could get the page to display with no errors.

Here is the code I tried to use:
// has the form been submitted? 
if ( bSubmitted ) 
{ 
   // get the data from the form... 
   sEmail = '' + Request.Form ( "email" );
   // validate the email address and moan if it fails 
   if ( sEmail != '' && !IsValidEmail ( sEmail, hexVeLevelDns ) ) 
   { 
      // pretend the form hasn't been sent yet 
      bSubmitted = false; 
   } 
}

Open in new window


Here is the code after modification that would allow the webpage finally display:
 ' has the form been submitted? 
if ( bSubmitted ) Then 
   ' get the data from the form... 
   sEmail = "" + Request.Form ( "email" )
   ' validate the email address and moan if it fails 
   if ( sEmail = "" ) then
      ' pretend the form hasn't been sent yet 
      bSubmitted = false
	  Request.write(sEmail)
	end if
end if

Open in new window


Is my page using an old version of .asp?  It is an old site but I got some code to return the ip address of the user and that worked
  Dim UserIPAddress
  UserIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
  If UserIPAddress = "" Then
    UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
  End If

Open in new window

so I'm just confused as to what's going on with this page.  Is it not asp?  Is it maybe vb?  It's been a few years since I've coded.  Maybe it's C#?  

Any help figuring out what's going on would be greatly appreciated!!
HSI_guelphAsked:
Who is Participating?
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Using classic asp and vbscript, here are a couple of solutions to send out mail using CDO

http://www.experts-exchange.com/Programming/Languages/Scripting/ASP/Q_28218900.html

http://www.experts-exchange.com/Programming/Languages/Scripting/ASP/Q_28173798.html

My main reference for both is from this site http://www.paulsadowski.com/wsh/cdo.htm

I suggest before you get to this part, you are able to submit a form, capture the data and print it to screen.

Also before sending out email, you should make sure any form data you capture is clean.  Always assume it contains harmful code and not the pure info you expect.

You can find a lot of useful files for classic asp here http://www.classicasp.org/
0
 
plusone3055Commented:
when this ASP.NET page was made it was made

ASP.NET with VB

The code you first tried was ASP.NET with C#
which is why it wasnt compiling

so just write teh code you want to write in VB.NET as you did to get it to display :)
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
the first two code blocks looks like javascript, which can be run server side for classic asp pages, but it's not common. at the top of the page, it should declare what language it is. it would be

<%@Language=VBScript%>

or

<%@language=javascript%>

do either of those lines show at the top of your page?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Classic asp is different from ASP.NET

IF you place this form on a page
<form action="test_page.asp" method="post">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>

Open in new window

Then on another page called test_page.asp add only this to test.
<%
if request.form("user")<>"" then
    response.write "No form input"
    else
    response.write "The form input was "&request.form("user")
end if
%>

Open in new window

0
 
HSI_guelphAuthor Commented:
@Scott Fell (padas) - It keeps coming up "No form input" even when I type something in the text box.

@Big Monty - sadly no there isn't anything at the top of the pages to indicate the language except for <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">  But I'm going to try adding one of those to see what happens.

@plusone3055 - It does look like VB script I've been adding to report code in SSRS.  

Some of the files in the folder are dated 2006 and I found one folder called "aspnet_client" with a subfolder "system_web" and one in that one "2_0_50727"  which I think might refer to a version being used.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
That means it is working.

Did you copy the first page exactly!
<form action="test_page.asp" method="post">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>

Open in new window

0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Try this for test_page.asp

<%
response.write request.form &"<hr>"&response.write request.querystring
%>
0
 
HSI_guelphAuthor Commented:
@Scott Fell (padas) - Yes I did but I tried some vb.net code and got this error on the page
Microsoft VBScript compilation  error '800a03f2'

Expected identifier

/consent.asp, line 13
Public Class Form1
-------^

Since it was Microsoft VBScript compilation error I think I need code in VBScript.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
You want this code at the very top
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

The reason you see the folders for "aspnet_client" might be default folders or are there a lot of files in those folders?
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
You have to decide if you are using classic asp which is what I am giving you OR ASP.NET, not both.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
You might want to read up on classic asp and/or .net.  They are completely different.

http://www.w3schools.com/asp/

http://www.asp.net/get-started
0
 
HSI_guelphAuthor Commented:
They are empty

I added that to the top of the page but it still says
Microsoft VBScript compilation  error '800a03f2'

Expected identifier

/consent.asp, line 14
Public Class Form1
-------^
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
what is line 14 on consent.asp? did you try adding

<%language=javascript%> at the top of the page?
0
 
HSI_guelphAuthor Commented:
Yes unfortunately no one in the company coded the page so I don't know which version they used or planned to use.  Response.Write works for me and any code with {}'s won't display so I'm gonna go on a limb and say it is classic asp but does the fact the error message mentions VBScript matter?
0
 
HSI_guelphAuthor Commented:
@Big Monty - I added the javascript tag to the top under the vbscript one and I got

Microsoft VBScript compilation  error '800a03f2'

Expected identifier

/consent.asp, line 15
Public Class Form1
-------^

code
It seems to hate the Public Class object.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
it IS classic asp, you can tell by the extension of asp (.NET has an extension of ASPX). Whether it's coded in vbscript or javascript is what we're trying to determine, to me it looks to be javascript. if it is, you need to declare that at the top of the page
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
ok, you're still mixing up classic asp and .NET, the IMPORTS keyword is for .NET, thats why its failing. also, take out the javascript reference, it looks like its using vbscript
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
the class code you have is also for .NET, it looks like this was done in .NET but somehow the file got renamed to .asp, which would cause all of these errors you're getting.

i bet if you rename it back to an aspx extension, it'll probably run w/out error.
0
 
HSI_guelphAuthor Commented:
I tried renaming it to .aspx and this is the error I got

Server Error in '/' Application.

Runtime Error
  Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".



<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
 

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.



<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>
 

The code that is not working is what I'm trying to add to the page.  So that code was not there originally.  So I should look for code examples that use classic asp?  Not VBScript?
The page is basically an html page named .asp.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
it may help to post the entire pages code, that way we can see exactly what language it is. otherwise it's all guesswork
0
 
HSI_guelphAuthor Commented:
I had been trying a bunch of stuff so I grabbed the original page I based my work off of that way I was sure none of my experimenting was left in the code I show

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>company Incorporated</title>

<link rel="stylesheet" href="styles.css" type="text/css">

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body background="images/english/site/back.gif" link="097582" vlink="097582" alink="a37f5a" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/english/site/home_on.gif','images/english/site/who_on.gif','images/english/site/clients_on.gif','images/english/site/cando_on.gif','images/english/site/portfolio_on.gif','images/english/site/right_on.gif','images/english/site/what_on.gif','images/english/site/career_on.gif','images/english/site/contact_on.gif','images/english/site/sitemap_on.gif','images/english/site/button_on.gif')">

<!-- ClickTale Top part -->
<script type="text/javascript">
var WRInitTime=(new Date()).getTime();
</script>
<!-- ClickTale end of Top part -->

<table border="0" cellpadding="0" cellspacing="0" width="765" align="center">
	<tr>
		<td align="left" valign="top" colspan="2" width="765"><img src="images/english/site/top_bar.gif" alt=""></td>
	</tr>
	<tr>
		<td align="left" valign="top" colspan="2" width="765">
		<table border="0" cellpadding="0" cellspacing="0" width="765">
			<tr>
				<td align="left" valign="top">
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td align="left" valign="top"><a href="index.html"><img src="images/english/site/logo.gif" alt="companyTEMS Incorporated" border="0"></a></td>
					</tr>
					<tr>
						<td align="left" valign="top"><img src="images/english/site/fade.gif" alt=""></td>
					</tr>
				</table>
				</td>
				<td align="left" valign="top">
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td align="left" valign="top"><img src="images/english/site/tagline.gif" alt=""></td>
					</tr>
					<tr>
						<td align="left" valign="top"><img src="images/english/site/contact_pics.jpg" alt=""></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td align="left" valign="top" width="216"><img src="images/english/site/left_spacer.gif" alt=""></td>
		<td align="left" valign="top" width="549"><img src="images/english/site/right_spacer2.gif" alt=""></td>
	</tr>
<!-- END HEADER -->
<!-- CONTENT -->
	<tr>
<!-- menu -->	<td align="left" valign="top" width="216" background="images/english/site/left_back.gif">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td align="left" valign="top"><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('home','','images/english/site/home_on.gif',1)"><img src="images/english/site/home_off.gif" alt="Home" name="home" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><a href="who.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('whoweare','','images/english/site/who_on.gif',1)"><img src="images/english/site/who_off.gif" alt="Who We Are" name="whoweare" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><a href="clients.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('clients','','images/english/site/clients_on.gif',1)"><img src="images/english/site/clients_off.gif" alt="Our Clients" name="clients" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><a href="cando.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('wecando','','images/english/site/cando_on.gif',1)"><img src="images/english/site/cando_off.gif" alt="What We Can Do" name="wecando" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><a href="portfolio.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('projport','','images/english/site/portfolio_on.gif',1)"><img src="images/english/site/portfolio_off.gif" alt="Project Portfolio" name="projport" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><a href="choice.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('rightchoice','','images/english/site/right_on.gif',1)"><img src="images/english/site/right_off.gif" alt="Why We're the Right Choice" name="rightchoice" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><a href="hf.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('whatishf','','images/english/site/what_on.gif',1)"><img src="images/english/site/what_off.gif" alt="What is Human Factors?" name="whatishf" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><a href="career.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('career','','images/english/site/career_on.gif',1)"><img src="images/english/site/career_off.gif" alt="Career Opportunities" name="career" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><img src="images/english/site/contact_on.gif" alt="Contact Us" name="contact" width="216" height="28" border="0"></td>
			</tr>
			<tr>
				<td align="left" valign="top" background="images/english/site/subnav_back.gif" width="216">
				<table border="0" cellpadding="0" cellspacing="14" align="right">
					<tr>
						<td align="right" valign="top"><font class="general2"><a href="map.html" class="subnav"><font color="ccffff">Map</font></a></font></td>
					</tr>
					<tr>
						<td align="right" valign="top"><font class="general2"><a href="directions.html" class="subnav"><font color="ccffff">Directions</font></a></font></td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td align="left" valign="top"><a href="sitemap.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('sitemap','','images/english/site/sitemap_on.gif',1)"><img src="images/english/site/sitemap_off.gif" alt="Site Map" name="sitemap" width="216" height="28" border="0"></a></td>
			</tr>
			<tr>
				<td align="left" valign="top"><img src="images/english/site/menu_spacer.gif" alt=""></td>
			</tr>
		</table>
		</td>
		<td align="left" valign="top" width="549">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td align="left" valign="top" width="2"><img src="images/english/site/header/contact_header_line.gif" alt=""></td>
				<td align="left" valign="top" width="547">
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
<!-- subhead -->				<td align="left" valign="top"><img src="images/english/site/header/contact_header.gif" alt="Contact Us"></td>
					</tr>
					<tr>
						<td align="left" valign="top">
						<table border="0" cellpadding="0" cellspacing="15" width=100%>
							<tr>
<!-- copy -->					<td align="left" valign="top">
								<font class="general">To learn more about who we are, what we do and how we can help you integrate Human Factors into your project, please contact us or fill out the form below.
								<p>
								<table border="0" cellpadding="0" cellspacing="0" align="center">
									<tr>
										<td align="left" valign="top" bgcolor="acacac">
										<table border="0" cellpadding="0" cellspacing="1">
											<tr>
												<td align="left" valign="top" bgcolor="ffffff">
												<table border="0" cellpadding="10" cellspacing="1">
													<tr>
														<td align="left" valign="top" bgcolor="eeeeee" width="150"><font class="general"><b>HEAD OFFICE</b><br>
														111 Farquhar Street<br>
														Guelph, Ontario<br>
														Canada<br>
														N1H 3N4<br>

														<p>Telephone:<br>
														1-519-836-5911<br>
														Facsimile:<br>
														1-519-836-1722
														<p><b>Bob Webb</b>,<br>
														President & Principal Consultant<br>
														<a href="contactform.asp?recipient=webb">Contact Us</a>

														<!-- <p><b>Kim Gross  ,</b><br>
														Manager - Business Development<br>
														<a href="contactform.asp?recipient=kgross">Contact Us</a> -->

														<p align="center"><a href="map.html"><img src="images/english/site/map_button.gif" border="0" alt="Map"></a></p>
														<p align="center"><a href="directions.html"><img src="images/english/site/directions_button.gif" border="0" alt="Directions"></a></p>

														</font></td>
														<td align="left" valign="top" bgcolor="eeeeee" width="150"><font class="general"><b>OTTAWA OFFICE</b><br>
														Telephone:<br>
														1-613-831-9998
														
														<p><b>Ron Boothby</b>,<br>
														Senior Consultant<br>
														<a href="contactform.asp?recipient=rboothby">Contact Us</a></font></td>
														
														<!-- <td align="left" valign="top" bgcolor="eeeeee"><font class="general"><b>HALIFAX OFFICE</b><br>
														Roy Keeble,<br>
														Consultant<br>
														
														<p>Telephone:<br>
														1-902-425-3701

														<p><a href="contactform.asp?recipient=rkeeble">Contact Us</a></font></td> -->
												</table>
												</td>
											</tr>
										</table>
										</td>
									</tr>
								</table>
								<p>
								</td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
<!-- END CONTENT -->
<!-- FOOTER -->
	<tr>
		<td align="left" valign="top" colspan="2"><img src="images/english/site/footer_bar.gif" alt="www.company.com"></td>
	</tr>
</table>
<!-- code added by vl:sri on 14-05-2008-->
<script type="text/javascript">

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

</script>

<script type="text/javascript">

var pageTracker = _gat._getTracker("UA-4408942-1");

pageTracker._initData();

pageTracker._trackPageview();

</script>
<!-- code ends here-->

<!-- ClickTale Bottom part -->
<div id="ClickTaleDiv" style="display: none;"></div>
<script type="text/javascript">
if(document.location.protocol!='https:')
  document.write(unescape("%3Cscript%20src='http://s.clicktale.net/WRb6.js'%20type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
if(typeof ClickTale=='function') ClickTale(8352,1,"www03");
</script>
<!-- ClickTale end of Bottom part -->

</body>
</html>
 

Open in new window

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
there doesn't seem to be any server side code in this page, nothing dynamic. what was the page with the class in it for?
0
 
HSI_guelphAuthor Commented:
I was trying to make the page dynamic by adding a form that would send the information to an email.  I'm trying to add an html form and have it call code to submit the information added to an email set up to receive those forms.  I just couldn't figure out why the code I was using wasn't working but I see it was the mix up between classic ASP, ASP.NET, and VBScript.  I'm trying the code from the w3schools to see if I can get it working now.

I did have some code working but it was sending emails every time the page was loaded, lol.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Classic ASP is either paired with serverside vbscript or serveside jscript.  You really should just use vbscript.  Jscript is Microsoft's implementation of serverside javscript and runs very slow.
0
 
HSI_guelphAuthor Commented:
TYVM!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.