Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET form won't submit

Status
Not open for further replies.

locutis

Programmer
Nov 3, 2006
53
US
Hello, I'm using ASP 1.1.4322 framework. I have an e-mail send form in ASP.NET/C# code behind. It was working, then I added some form fields, made sure to build again, now I can't get the form to submit. I tried setting breakpoints, Console.WriteLine statements throughout, it seems that the btnSend_Click may not even be getting called now. It's a really nice little app, can someone please just take a look and see what the heck it is I'm missing here? Anyone is welcome to use it, but I would really appreciate some help finding what the problem is. Let me know where I can send you the aspx and aspx.cs files.

Thanks,
Jean Luc
 
Let me know where I can send you the aspx and aspx.cs files.
You'll have to paste the contents into this thread so that everyone can see them. Please use [ignore]
Code:
[/ignore] tags when doing so.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
OK, here goes. send.aspx and send.aspx.cs:

send.aspx:
Code:
<%@ Page language="c#" Codebehind="Send.aspx.cs" AutoEventWireup="false" Inherits="MailWebService.Form1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<TITLE>Test - Request For Quote</TITLE>
		<meta name="Description" content="Test">
		<meta name="KeyWords" content="Test">	
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<meta name="Copyright" content="Copyright 2004 Test [URL unfurl="true"]http://www.test.com/">[/URL]
		<META http-equiv="Content-Language" content="en">
		<META name="revisit-after" content="15 days">
		<META name="robots" content="index, follow">
		<META name="Rating" content="General">
		<META name="Robots" content="All">
		<meta content="[URL unfurl="true"]http://schemas.microsoft.com/intellisense/ie5"[/URL] name="vs_targetSchema">
		
		<link rel=StyleSheet href="corporatestyle.css" type="text/css" media="screen">
		<style type="text/css">TD { FONT-SIZE: 10pt; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif }
		.width386 { WIDTH: 386px }
		.basic { FONT-SIZE: 10pt; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif }
		.titl { FONT-WEIGHT: bold; FONT-SIZE: 13pt; COLOR: #ffffff; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif }
		</style>
		<script language="JavaScript" src="javascripts.js"></script>
		<script language="JavaScript" src="scroller/scroll.js"></script>
	</HEAD>
	<BODY BGCOLOR="#FFFFFF" background="picts/background-main.gif" TEXT="#000000" LINK="#339966" VLINK="#663399" ALINK="#666666" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" onload="javascript:document.all.txtUsername.focus()">
		
		<!-- PAGE TABLE-->
		<TABLE cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td ALIGN="LEFT" VALIGN="TOP">

		<script language="JavaScript" src="header.js"></script>

		<!-- PICTURE TABLE -->
		<TABLE cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td background="picts/contact.jpg">
		<a href="../index.asp"><IMG SRC="picts/spacer.gif" border="0" width="700" height="80"></a><br>
		</td></tr>
		</TABLE>
		<!-- PICTURE TABLE -->
		
		<img src="picts/stretchbar.jpg" width="100%" height="28"><br>
		
		<script language="JavaScript" src="menu.js"></script>
		
		<!-- CORNER TABLE -->
		<TABLE cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/shadow1.gif"><tr><td width="227">
		<IMG SRC="picts/corner.gif" height="40" width="227"><br>
		</td><td>
		<IMG SRC="picts/spacer.gif" height="40" width="10" border="0"><br>
		</td></tr>
		</TABLE>
		<!-- CORNER TABLE -->
		
		<!-- OUTER TABLE-->
		<TABLE cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td ALIGN="left" VALIGN="top">

		<!-- SPLIT TABLE-->
		<TABLE cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td ALIGN="LEFT" VALIGN="TOP" width="15">
		<IMG SRC="picts/spacer.gif" height="10" width="15" border="0"><br>
		</td><td ALIGN="LEFT" VALIGN="TOP" width="150">
		
		<script language="JavaScript" src="sidebar.js"></script>
		
		<IMG SRC="picts/spacer.gif" height="5" width="150" border="0"><br>

		</td><td ALIGN="LEFT" VALIGN="TOP" width="30">

		<IMG SRC="picts/spacer.gif" height="400" width="30" border="0"><br>

		</td><td ALIGN="CENTER" VALIGN="TOP">

		<!-- START CONTENT TABLE -->
		<TABLE cellpadding="0" cellspacing="0" border="0" width="475"><tr><td ALIGN="LEFT" VALIGN="TOP">

		<p class="just">

		<!-- COPY AND PASTE CODE BELOW TO MAKE A NEW PARAGRAPH -->
		<span class="subtitle">
		</span>
		
		<BR>
		<!-- COPY AND PASTE CODE ABOVE TO MAKE A NEW PARAGRAPH -->
		<TABLE BORDER="0" WIDTH="90%" CELLPADDING="10" ALIGN="center">
		<TR> 
		<TD COLSPAN="2"> 
		<blockquote> 
				<div align="left"> 
				
		<!-- COPY AND PASTE CODE BELOW TO MAKE A NEW HEADING -->
		<span class="title">
			<IMG SRC="picts/logo-sm3.gif" border="0" align="right"><BR><BR><BR>
		</span>
		<span class="title">
			Request for Quote<BR>
		</span>
		<IMG SRC="picts/paragraph-line.jpg" HEIGHT="3" WIDTH="100%" border="0" vspace="7">
		<!-- COPY AND PASTE CODE ABOVE TO MAKE A NEW HEADING -->
		
		<div align="center"><asp:label id="lblMessage" Visible="False" Width="540" Font-Size="X-Small" Font-Names="Arial"
				runat="server"></asp:label></div>
	
		<div align="center">
			<form id="Form1" name="form1" method="post" encType="multipart/form-data" runat="server">
				<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="Name or Contact cannot be blank"
					ControlToValidate="txtUsername" Display="Dynamic"></asp:RequiredFieldValidator><br>
				<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ErrorMessage="E-mail Address cannot be blank"
					ControlToValidate="txtSender" Display="Dynamic"></asp:RequiredFieldValidator><br>
				<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Your entry is not a valid e-mail address"
					ControlToValidate="txtSender" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
				<table cellSpacing="0" cellPadding="4" bgColor="#ffffff" border="0">
					<tr>
						<td style="HEIGHT: 380px">
							<table cellSpacing="3" cellPadding="4" width="640" bgColor="white">
								<tr>
									<td colSpan="2">
										<div align="center"><font face="Verdana, Helvetica, Arial" size="2">Please fill out 
												this form with as much information as possible. If your browser is not set up 
												for e-mail then print and fax this form to (562) 693-4936:</font>
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div align="center"><font face="Verdana, Helvetica, Arial"><b>* Required</b></font></div>
									</td>
								</tr>
								<tr bgColor="#e6e6ff">
									<td colSpan="2" height="40">
										<div align="center"><font face="Verdana, Helvetica, Arial"><b>Tell Us About You</b></font></div>
									</td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">* Your Name or Contact</td>
									<td><asp:textbox id="txtUsername" tabIndex="1" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Company</td>
									<td><asp:textbox id="txtCompany" tabIndex="2" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Street Address</td>
									<td><asp:textbox id="txtAddress1" tabIndex="3" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Street Address 2</td>
									<td><asp:textbox id="txtAddress2" tabIndex="4" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">City</td>
									<td><asp:textbox id="txtCity" tabIndex="5" Width="386px" Font-Size="X-Small" Font-Names="Arial" runat="server"
											CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">State</td>
									<td><asp:textbox id="txtState" tabIndex="6" Width="25px" Font-Size="X-Small" Font-Names="Arial" runat="server"
											CssClass="width386" MaxLength="2"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Zip</td>
									<td><asp:textbox id="txtZip" tabIndex="7" Width="100px" Font-Size="X-Small" Font-Names="Arial" runat="server"
											CssClass="width386" MaxLength="10"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Phone</td>
									<td><asp:textbox id="txtPhone" tabIndex="8" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Fax</td>
									<td><asp:textbox id="txtFax" tabIndex="9" Width="386px" Font-Size="X-Small" Font-Names="Arial" runat="server"
											CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">* E-mail Address:</td>
									<td><asp:textbox id="txtSender" tabIndex="10" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr bgColor="#e6e6ff">
									<td colSpan="2" height="40">
										<div align="center"><font face="Verdana, Helvetica, Arial"><b>Tell Us About Your Project</b></font></div>
									</td>
								</tr>
								<tr>
									<td style="HEIGHT: 44px" vAlign="middle" align="right">Tell us about your 
										application:</td>
									<td style="HEIGHT: 44px"><asp:radiobuttonlist id="needStatusList" tabIndex="11" runat="server" repeatdirection="Horizontal" repeatcolumns="3">
											<asp:ListItem Value="Immediate">Immediate</asp:ListItem>
											<asp:ListItem Value="Intermediate">Intermediate</asp:ListItem>
											<asp:ListItem Value="Future">Future</asp:ListItem>
										</asp:radiobuttonlist></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Part No.:</td>
									<td><asp:textbox id="txtPartNumber" tabIndex="12" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Part Name:</td>
									<td><asp:textbox id="txtPartName" tabIndex="13" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td style="HEIGHT: 44px" vAlign="middle" align="right">Print Drawing Available:</td>
									<td style="HEIGHT: 44px"><asp:radiobuttonlist id="printDrawingList" tabIndex="14" runat="server" repeatdirection="Horizontal"
											repeatcolumns="2">
											<asp:ListItem Value="Yes">Yes</asp:ListItem>
											<asp:ListItem Value="No">No</asp:ListItem>
										</asp:radiobuttonlist></td>
								</tr>
								<tr>
									<td style="HEIGHT: 44px" vAlign="middle" align="right">Sample Parts Available:</td>
									<td style="HEIGHT: 44px"><asp:radiobuttonlist id="samplePartsList" tabIndex="15" runat="server" repeatdirection="Horizontal" repeatcolumns="2">
											<asp:ListItem Value="Yes">Yes</asp:ListItem>
											<asp:ListItem Value="No">No</asp:ListItem>
										</asp:radiobuttonlist></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Material Requirements:</td>
									<td><asp:textbox id="txtMaterialRequirements" tabIndex="16" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Specification:</td>
									<td><asp:textbox id="txtSpecification" tabIndex="17" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td style="HEIGHT: 44px" vAlign="middle" align="right">Prototypes Needed:</td>
									<td style="HEIGHT: 44px"><asp:radiobuttonlist id="prototypesNeededList" tabIndex="18" runat="server" repeatdirection="Horizontal"
											repeatcolumns="2">
											<asp:ListItem Value="Yes">Yes</asp:ListItem>
											<asp:ListItem Value="No">No</asp:ListItem>
										</asp:radiobuttonlist></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Initial Quantity:</td>
									<td><asp:textbox id="txtInitialQuantity" tabIndex="19" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Production Quantity:</td>
									<td><asp:textbox id="txtProductionQuantity" tabIndex="20" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Qualification Samples:</td>
									<td><asp:textbox id="txtQualificationSamples" tabIndex="21" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">How will this part be used?</td>
									<td>Pressure:<asp:textbox id="txtPressure" tabIndex="22" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox>&nbsp; 
										Temperature:<asp:textbox id="txtTemperature" tabIndex="23" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox>
									</td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">What media will this part be exposed to?</td>
									<td><asp:textbox id="txtMedia" tabIndex="24" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Mechanical Environment:</td>
									<td><asp:textbox id="txtMechancalEnvironment" tabIndex="25" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td style="HEIGHT: 44px" vAlign="middle" align="right">Does this part require and 
										insert?</td>
									<td style="HEIGHT: 44px"><asp:radiobuttonlist id="insertRequiredList" tabIndex="26" runat="server" repeatdirection="Horizontal"
											repeatcolumns="2">
											<asp:ListItem Value="Yes">Yes</asp:ListItem>
											<asp:ListItem Value="No">No</asp:ListItem>
										</asp:radiobuttonlist><asp:dropdownlist id="insertTypeDropDownList" runat="server" tabIndex="27">
											<asp:ListItem Value="Overmolded">Overmolded</asp:ListItem>
											<asp:ListItem Value="Bonded">Bonded</asp:ListItem>
										</asp:dropdownlist></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Insert Furnished By:</td>
									<td><asp:textbox id="txtInsertFurnishedBy" tabIndex="28" Width="386px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Insert No:</td>
									<td><asp:textbox id="txtInsertNumber" tabIndex="29" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td style="HEIGHT: 44px" vAlign="middle" align="right">Plating:</td>
									<td style="HEIGHT: 44px"><asp:radiobuttonlist id="platingRequiredList" tabIndex="30" runat="server" repeatdirection="Horizontal"
											repeatcolumns="2">
											<asp:ListItem Value="Yes">Yes</asp:ListItem>
											<asp:ListItem Value="No">No</asp:ListItem>
										</asp:radiobuttonlist></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">What type of tooling is needed for this part?</td>
									<td>New:<asp:textbox id="txtToolingType1" tabIndex="31" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox>&nbsp; 
										Existing:<asp:textbox id="txtToolingType2" tabIndex="32" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox>
									</td>
								</tr>
								<tr>
									<td style="HEIGHT: 44px" vAlign="middle" align="right">Type Mold:</td>
									<td style="HEIGHT: 44px"><asp:dropdownlist id="moldTypeDropDownList" runat="server" tabIndex="33">
											<asp:ListItem Value="Compression">Compression</asp:ListItem>
											<asp:ListItem Value="Transfer">Transfer</asp:ListItem>
											<asp:ListItem Value="Injection">Injection</asp:ListItem>
										</asp:dropdownlist></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">No. Cavities:</td>
									<td><asp:textbox id="txtNoCavities" tabIndex="34" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Transfer Pot Size:</td>
									<td><asp:textbox id="txtTransferPotSize" tabIndex="35" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Tool Dimensions:</td>
									<td>Height:<asp:textbox id="txtToolDimHeight" tabIndex="36" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox>&nbsp; 
										Width:<asp:textbox id="txtToolDimWidth" tabIndex="37" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox>
										Length:<asp:textbox id="txtToolDimLength" tabIndex="38" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox>
									</td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Target Price:</td>
									<td><asp:textbox id="txtTargetPrice" tabIndex="39" Width="100px" Font-Size="X-Small" Font-Names="Arial"
											runat="server" CssClass="width386" MaxLength="100"></asp:textbox></td>
								</tr>
								<tr bgColor="#e6e6ff">
									<td colSpan="2" height="40">
										<div align="center"><font face="Verdana, Helvetica, Arial"><b>Special Requirements<br>
												</b><font size="2">(Performance, Quality, Colors, Mounting, etc)</font></font>
										</div>
									</td>
								</tr>
								<tr>
									<td vAlign="top" align="right">Special Requirements:</td>
									<td height="84">
										<p><asp:textbox id="txtSpecialRequirements" tabIndex="40" Font-Size="X-Small" Font-Names="Arial"
												runat="server" CssClass="width386" width="451px" textmode="MultiLine" rows="5" columns="40"></asp:textbox></p>
									</td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Attachment:</td>
									<td><input id="ofdAttachment1" tabIndex="41" type="file" size="56" name="filMyFile" runat="server"></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Attachment:</td>
									<td><input id="ofdAttachment2" tabIndex="42" type="file" size="56" name="filMyFile" runat="server"></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Attachment:</td>
									<td><input id="ofdAttachment3" tabIndex="43" type="file" size="56" name="filMyFile" runat="server"></td>
								</tr>
								<tr>
									<td vAlign="middle" align="right">Format:</td>
									<td><asp:radiobuttonlist id="rblMailFormat" tabIndex="44" runat="server" repeatdirection="Horizontal" repeatcolumns="2">
											<asp:ListItem Value="text" Selected="True">text</asp:ListItem>
											<asp:ListItem Value="html">html</asp:ListItem>
										</asp:radiobuttonlist></td>
								</tr>
								<tr>
									<td align="center" colSpan="2"><asp:button id="btnSend" tabIndex="45" runat="server" width="100px" text="Send"></asp:button></td>
								</tr>
							</table>
							<asp:ValidationSummary id="ValidationSummary1" runat="server" HeaderText="Reminder:" DisplayMode="List"></asp:ValidationSummary>
						</td>
					</tr>
				</table>
			</form>
			
			</div>
			</blockquote>
			</TD>
			</TR>
			</TABLE>
			
			<br>
			<br>
</p>

</td></tr></TABLE>
<!-- END CONTENT TABLE -->

</td></tr></TABLE>

<!-- END SPLIT TABLE -->

</td></tr></TABLE>
<!-- END OUTER TABLE-->

<!-- PAGE TABLE-->
</TD></TR><TR><TD VALIGN="BOTTOM">

<img src="picts/stretchbar.jpg" width="100%" height="28"><br>

<!-- COPYRIGHT -->
<TABLE cellpadding="0" cellspacing="0" border="0" width="100%" background="picts/bottom-shade.gif"><tr><td width="10">
<IMG SRC="picts/spacer.gif" height="45" width="10" border="0"><br>

</td><td ALIGN="left" VALIGN="middle">

<script language="JavaScript" src="copyright.js"></script>

</td><td ALIGN="right" VALIGN="middle">

<script language="JavaScript" src="copyright.js"></script>

</TD><td width="10">

<IMG SRC="picts/spacer.gif" height="10" width="10" border="0"><br>

</td></tr></TABLE>
<!-- COPYRIGHT -->

</td></tr></TABLE>
<!-- END PAGE TABLE-->

</div>

</BODY>
</HTML>
send.aspx.cs:
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.IO;
using System.Web;
using System.Web.Mail;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace MailWebService
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lblMessage;
		protected System.Web.UI.WebControls.TextBox txtSender;
		protected System.Web.UI.WebControls.RadioButtonList rblMailFormat;
		protected System.Web.UI.WebControls.Button btnSend;
		protected System.Web.UI.HtmlControls.HtmlInputFile ofdAttachment1;
		protected System.Web.UI.HtmlControls.HtmlInputFile ofdAttachment2;
		protected System.Web.UI.HtmlControls.HtmlInputFile ofdAttachment3;
		protected System.Web.UI.WebControls.TextBox txtUsername;
		protected System.Web.UI.WebControls.TextBox txtCompany;
		protected System.Web.UI.WebControls.TextBox txtAddress2;
		protected System.Web.UI.WebControls.TextBox txtAddress1;
		protected System.Web.UI.WebControls.TextBox txtCity;
		protected System.Web.UI.WebControls.TextBox txtState;
		protected System.Web.UI.WebControls.TextBox txtZip;
		protected System.Web.UI.WebControls.TextBox txtPhone;
		protected System.Web.UI.WebControls.TextBox txtFax;
		protected System.Web.UI.WebControls.RadioButtonList needStatusList;
		protected System.Web.UI.WebControls.TextBox txtPartNumber;
		protected System.Web.UI.WebControls.TextBox txtPartName;
		protected System.Web.UI.WebControls.RadioButtonList printDrawingList;
		protected System.Web.UI.WebControls.RadioButtonList samplePartsList;
		protected System.Web.UI.WebControls.TextBox txtMaterialRequirements;
		protected System.Web.UI.WebControls.TextBox txtSpecification;
		protected System.Web.UI.WebControls.RadioButtonList prototypesNeededList;
		protected System.Web.UI.WebControls.TextBox txtInitialQuantity;
		protected System.Web.UI.WebControls.TextBox txtProductionQuantity;
		protected System.Web.UI.WebControls.TextBox Textbox3;
		protected System.Web.UI.WebControls.TextBox txtQualificationSamples;
		protected System.Web.UI.WebControls.TextBox txtSpecialRequirements;
		protected System.Web.UI.WebControls.TextBox txtPressure;
		protected System.Web.UI.WebControls.TextBox txtTemperature;
		protected System.Web.UI.WebControls.TextBox txtMedia;
		protected System.Web.UI.WebControls.TextBox txtMechancalEnvironment;
		protected System.Web.UI.WebControls.RadioButtonList insertRequiredList;
		protected System.Web.UI.WebControls.DropDownList insertTypeDropDownList;
		protected System.Web.UI.WebControls.TextBox txtInsertFurnishedBy;
		protected System.Web.UI.WebControls.TextBox txtInsertNumber;
		protected System.Web.UI.WebControls.RadioButtonList platingRequiredList;
		protected System.Web.UI.WebControls.TextBox txtToolingType1;
		protected System.Web.UI.WebControls.TextBox txtToolingType2;
		protected System.Web.UI.WebControls.DropDownList moldTypeDropDownList;
		protected System.Web.UI.WebControls.TextBox txtNoCavities;
		protected System.Web.UI.WebControls.TextBox txtTransferPotSize;
		protected System.Web.UI.WebControls.TextBox txtToolDimHeight;
		protected System.Web.UI.WebControls.TextBox txtToolDimWidth;
		protected System.Web.UI.WebControls.TextBox txtToolDimLength;
		protected System.Web.UI.WebControls.TextBox txtTargetPrice;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected string strFileName;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
		protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
		protected string strBody;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnSend_Click(object sender, System.EventArgs e)
		{
			try
			{
				// Create a new blank MailMessage
				MailMessage email = new MailMessage ();


				// Set the properties of the MailMessage to the
				// values on the form
				if (rblMailFormat.SelectedItem.Text == "text")
					email.BodyFormat = MailFormat.Text;
				else
					email.BodyFormat = MailFormat.Html;
				email.From = txtSender.Text;
				email.To = "test@gmail.com";
				email.Subject = "REQUEST FOR QUOTE from " + txtUsername.Text;

				strBody = strBody + "Name: "  + txtUsername.Text + "<br>"; //Replace("\r\n", "<br>");
				strBody = strBody + "Company: "  + txtCompany.Text + "<br>";
				strBody = strBody + "Address 1: "  + txtAddress1.Text + "<br>";
				strBody = strBody + "Address 2: "  + txtAddress2.Text + "<br>";
				strBody = strBody + "City: "  + txtCity.Text + "<br>";
				strBody = strBody + "State: "  + txtState.Text + "<br>";
				strBody = strBody + "Zip: "  + txtZip.Text + "<br>";
				strBody = strBody + "Phone: "  + txtPhone.Text + "<br>";
				strBody = strBody + "Fax: "  + txtFax.Text + "<br>";
				strBody = strBody + "E-Mail: "  + txtSender.Text + "<br>";
				strBody = strBody + "Need: "  + needStatusList.SelectedValue + "<br>";
				strBody = strBody + "Part Number: "  + txtPartNumber.Text + "<br>";
				strBody = strBody + "Part Name: "  + txtPartName.Text + "<br>";
				strBody = strBody + "Print: "  + printDrawingList.SelectedValue + "<br>";
				strBody = strBody + "Samples: "  + samplePartsList.SelectedValue + "<br>";
				strBody = strBody + "Material: "  + txtMaterialRequirements.Text + "<br>";
				strBody = strBody + "Specification: "  + txtSpecification.Text + "<br>";
				strBody = strBody + "Prototypes: "  + prototypesNeededList.SelectedValue + "<br>";
				strBody = strBody + "Initial Quantity: "  + txtInitialQuantity.Text + "<br>";
				strBody = strBody + "Product Quantity: "  + txtProductionQuantity.Text + "<br>";
				strBody = strBody + "Qualification Samples: "  + txtQualificationSamples.Text + "<br>";
				strBody = strBody + "Pressure: "  + txtPressure.Text + "<br>";
				strBody = strBody + "Temperature: "  + txtTemperature.Text + "<br>";
				strBody = strBody + "Media: "  + txtMedia.Text + "<br>";
				strBody = strBody + "Mechanical Environment: "  + txtMechancalEnvironment.Text + "<br>";
				strBody = strBody + "Inserts: "  + insertRequiredList.SelectedValue + "<br>";
				strBody = strBody + "Type Insert: "  + insertTypeDropDownList.SelectedValue + "<br>";
				strBody = strBody + "Furnished By: "  + txtInsertFurnishedBy.Text + "<br>";
				strBody = strBody + "Insert Number: "  + txtInsertNumber.Text + "<br>";
				strBody = strBody + "Plating: "  + platingRequiredList.SelectedValue + "<br>";
				strBody = strBody + "Tool New: "  + txtToolingType1.Text + "<br>";
				strBody = strBody + "Tool Existing: "  + txtToolingType2.Text + "<br>";
				strBody = strBody + "Type Mold: "  + moldTypeDropDownList.SelectedValue + "<br>";
				strBody = strBody + "Number of Cavities: "  + txtNoCavities.Text + "<br>";
				strBody = strBody + "Transfer Pot Size: "  + txtTransferPotSize.Text + "<br>";
				strBody = strBody + "Mold Height: "  + txtToolDimHeight.Text + "<br>";
				strBody = strBody + "Mold Width: "  + txtToolDimWidth.Text + "<br>";
				strBody = strBody + "Mold Length: "  + txtToolDimLength.Text + "<br>";
				strBody = strBody + "Target Price: "  + txtTargetPrice.Text + "<br>";
				strBody = strBody + "Special Requirements: "  + txtSpecialRequirements.Text;

				email.Body = strBody;
            
				// We use the 3 following variables to keep track of
				// attachments so we can delete them and strFileName is
				// used also for the name of the file attachment being 
				// processed.
				string attach1 = null;
				string attach2 = null;
				string attach3 = null;
				string strFileName = null;

				// Beginning of attachments processing
				// Check the first open file dialog for a value
				if (ofdAttachment1.PostedFile != null)
				{
					// Get a reference to PostedFile object
					HttpPostedFile ulFile = ofdAttachment1.PostedFile;
					// Get size of the file
					int nFileLen = ulFile.ContentLength; 
					// Make sure the size of the file is > 0
					if( nFileLen > 0 )
					{
						// Get the file name
						strFileName = Path.GetFileName(ofdAttachment1.PostedFile.FileName);
						// Preceed the file name with "attachments/" so 
						// the file is saved to our attachments directory
						strFileName = "attachments/" + strFileName;
						// Save the file on the server
						ofdAttachment1.PostedFile.SaveAs(Server.MapPath(strFileName));
						// Create the email attachment with the uploaded file
						MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
						// Attach the newly created email attachment
						email.Attachments.Add(attach);
						// Store filename so we can delete it later
						attach1 = strFileName;
					}
				}
				// Repeat previous step if there is an attachment #2
				if (ofdAttachment2.PostedFile != null)
				{
					HttpPostedFile ulFile = ofdAttachment2.PostedFile;
					int nFileLen = ulFile.ContentLength; 
					if( nFileLen > 0 )
					{
						strFileName = Path.GetFileName(ofdAttachment2.PostedFile.FileName);
						strFileName = "attachments/" + strFileName;
						ofdAttachment2.PostedFile.SaveAs(Server.MapPath(strFileName));
						MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
						email.Attachments.Add(attach);
						attach2 = strFileName;
					}
				}
				// Repeat previous step if there is an attachment #3
				if (ofdAttachment3.PostedFile != null)
				{
					HttpPostedFile ulFile = ofdAttachment3.PostedFile;
					int nFileLen = ulFile.ContentLength; 
					if( nFileLen > 0 )
					{
						strFileName = Path.GetFileName(ofdAttachment3.PostedFile.FileName);
						strFileName = "attachments/" + strFileName;
						ofdAttachment3.PostedFile.SaveAs(Server.MapPath(strFileName));
						MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
						email.Attachments.Add(attach);
						attach3 = strFileName;
					}
				}
				// End of attachments processing
            
				// Set the SMTP server and send the email
				SmtpMail.SmtpServer = "localhost";
				SmtpMail.Send (email);

				// Delete the attachments if any
				if (attach1 != null)
					File.Delete(Server.MapPath(attach1));
				if (attach2 != null)
					File.Delete(Server.MapPath(attach2));
				if (attach3 != null)
					File.Delete(Server.MapPath(attach3));	

				// Reset the form
				txtUsername.Text = "";
				txtCompany.Text = "";
				txtAddress1.Text = "";
				txtAddress2.Text = "";
				txtCity.Text = "";
				txtState.Text = "";
				txtZip.Text = "";
				txtPhone.Text = "";
				txtFax.Text = "";
				txtSender.Text = "";
				needStatusList.SelectedValue = "";
				txtPartNumber.Text = "";
				txtPartName.Text = "";
				printDrawingList.SelectedValue = "";
				samplePartsList.SelectedValue = "";
				txtMaterialRequirements.Text = "";
				txtSpecification.Text = "";
				prototypesNeededList.SelectedValue = "";
				txtInitialQuantity.Text = "";
				txtProductionQuantity.Text = "";
				txtQualificationSamples.Text = "";
				txtPressure.Text = "";
				txtTemperature.Text = "";
				txtMedia.Text = "";
				txtMechancalEnvironment.Text = "";
				insertRequiredList.SelectedValue = "";
				insertTypeDropDownList.SelectedValue = "";
				txtInsertFurnishedBy.Text = "";
				txtInsertNumber.Text = "";
				platingRequiredList.SelectedValue = "";;
				txtToolingType1.Text = "";
				txtToolingType2.Text = "";
				moldTypeDropDownList.SelectedValue = "";
				txtNoCavities.Text = "";
				txtTransferPotSize.Text = "";
				txtToolDimHeight.Text = "";
				txtToolDimWidth.Text = "";
				txtToolDimLength.Text = "";
				txtTargetPrice.Text = "";
				txtSpecialRequirements.Text = "";

				// Dispaly a friendly message telling the user
				// his email has been sent
				lblMessage.Visible = true;
				lblMessage.ForeColor = Color.Black;
				lblMessage.Text = "Your email has been sent";
			}
			catch(Exception ex)
			{
				// Print a much less friendly message informing the 
				// user about the exception that was risen
				lblMessage.Visible = true;
				lblMessage.ForeColor = Color.Red;
				lblMessage.Text = ex.ToString();
			}			
		}
	}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top