I'm new to ASP. I have a simple contact form - text fields only - and the results are emailed. But I can't get the page to display. I get a Runtime Error.

<%@ Page Language="C#" MasterPageFile="~/SiteMaster.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="contact_me_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<div id="iCntnr">
    <div id="contact_meCntnr">
        <asp:PlaceHolder ID="formPH" runat="server" Visible="true"> 
			<h3>I want to use stimulus money to clean my community's waterways.</h3>
			<p>Please contact me with more information.</p>
    	<form id="form1" runat="server"> 
		<table id="contact" cellspacing="0"> 
				<td>First Name:</td> 
				<td><asp:TextBox ID="FNameTB" runat="server" /> 
					<asp:RequiredFieldValidator ControlToValidate="FNameTB" ID="reqFirstName" runat="server" CssClass="error" Text="First Name is a required field">First Name is a required field</asp:RequiredFieldValidator> 
				<td>Last Name:</td> 
				<td><asp:TextBox ID="LNameTB" runat="server" /> 
					<asp:RequiredFieldValidator ControlToValidate="LNameTB" ID="reqLastName" runat="server" CssClass="error" Text="Last Name is a required field">Last Name is a required field</asp:RequiredFieldValidator> 
				<td><asp:TextBox ID="EmailTB" runat="server" /> 
					<asp:RequiredFieldValidator Display="Dynamic" ControlToValidate="EmailTB" ID="reqEmail"  runat="server" CssClass="error" Text="E-mail is a required field">E-mail is required</asp:RequiredFieldValidator><asp:RegularExpressionValidator ControlToValidate="EmailTB" ID="regEmail" Display="Dynamic" runat="server" CssClass="error" Text="Invalid e-mail address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator> 
				<td><asp:TextBox ID="CommentsTB" runat="server" TextMode="MultiLine" /> 
            	<td colspan="2"><asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="SendMail"/><asp:Button ID="btnReset" runat="server" Text="Reset" OnClick="Reset"/></td> 
        <asp:PlaceHolder ID="sucessPH" runat="server" Visible="false"> 
		<p>Thank you for your submission.</p> 	

and here is the code file:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;

public partial class contact_me_Default : System.Web.UI.Page

    protected void Page_Load(object sender, EventArgs e)
        ((SiteMaster)this.Master).SetHeaderTitle("Contact Me");
    protected void SendMail(object sender, EventArgs e)
                MailMessage mail = new MailMessage();
				mail.From = new MailAddress(EmailTB.Text);
				mail.To.Add(new MailAddress(ConfigurationManager.AppSettings["emailCorporate"]));
		        mail.Subject = "Contact Me about using Stimulus Money"; 
		        mail.IsBodyHtml = true;
		        mail.Body = "First Name: " + FNameTB.Text + "<br />";
		        mail.Body += "Last Name: " + LNameTB.Text + "<br />";
		        mail.Body += "Email: " + EmailTB.Text + "<br />";
		        mail.Body += "Comments: " + CommentsTB.Text + "<br />";
        		SmtpClient client = new SmtpClient();
				client.Host = ConfigurationManager.AppSettings["emailHost"];
        		client.UseDefaultCredentials = true;
				formPH.Visible = false;
				sucessPH.Visible = true;
	protected void Reset(object s, EventArgs e)
		FNameTB.Text = "";
		LNameTB.Text = "";
		EmailTB.Text = "";
		CommentsTB.Text = ""; 
8 Years
Discussion Span
Last Post by __avd
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.