tempest4000
11-25-2009, 02:21 PM
I have been asked to amend a form written asp.net even though Im a PHP developer and have never used asp.net before!
I have added two new checkboxes to the form on the HTML page as below:
<input type="checkbox" id="brochure" runat="server" name="brochure" value="brochure" style="width:15px;height:15px;margin:0 10px 0 0 " />Please tick to request our brochure</p>
<input type="checkbox" id="furtherInfo" name="furtherInfo" runat="server" value="further information" style="width:15px;height:15px;margin:0 10px 0 0 " />Please tick if you do not wish to receive further information from us</p>
On the backend .cs page which does all the processing I have:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Net.Mail;
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 Yucca.Pentire.Dal;
using Yucca.Pentire.Utils;
public partial class contact : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Master.UpdateBodyTag("contactus");
Master.UpdateMetaDetails("contact");
PhoneTracking.ImageSwap();
phonenumber.Text = PhoneTracking.HeaderPhone;
submitbutton.Click += new ImageClickEventHandler(submitbutton_Click);
}
void submitbutton_Click(object sender, ImageClickEventArgs e)
{
if (ValdiateAllFields())
{
MailMessage msg = new MailMessage();
SmtpClient smtp = Smtp.CreateSMTP(1);
//CheckBox brochure = (CheckBox) PreviousPage.FindControl("brochure");
string strBody;
strBody = "<strong>Name: </strong>" + name.Value + "<br />";
strBody += "<strong>Email: </strong>" + email.Value + "<br />";
strBody += "<strong>Telephone: </strong>" + telephone.Value + "<br />";
strBody += "<strong>Address: </strong>" + address1.Value + "<br />";
strBody += "<strong>Address: </strong>" + address2.Value + "<br />";
strBody += "<strong>Address: </strong>" + address3.Value + "<br />";
strBody += "<strong>Address: </strong>" + towncity.Value + "<br />";
strBody += "<strong>Address: </strong>" + county.Value + "<br />";
strBody += "<strong>Address: </strong>" + postcode.Value + "<br /><br />";
strBody += "<strong>Comments: </strong>" + comments.Value + "<br /><br />";
//strBody += "<strong>Brochure: </strong>" + brochure.Value + "<br /><br />";
// strBody += "<strong>Further Info: </strong>" + furtherInfo.Value + "<br /><br />";
//msg.From = new MailAddress("bookings@pentirehaven.co.uk");
//msg.To.Add(new MailAddress("bookings@pentirehaven.co.uk"));
msg.To.Add(new MailAddress("leannetempest@yahoo.co.uk"));
msg.Subject = "Enquiry";
msg.Body = strBody;
msg.IsBodyHtml = true;
smtp.Send(msg);
headersentmessage.Visible = true;
Response.Redirect("~/contact_amended.aspx");
}
}
This works unless I uncomment out the lines of code relating to the two new checkboxes and I get the error message:
CS0103: The name 'brochure' does not exist in the current context
Can anyone help? Many thanks...
I have added two new checkboxes to the form on the HTML page as below:
<input type="checkbox" id="brochure" runat="server" name="brochure" value="brochure" style="width:15px;height:15px;margin:0 10px 0 0 " />Please tick to request our brochure</p>
<input type="checkbox" id="furtherInfo" name="furtherInfo" runat="server" value="further information" style="width:15px;height:15px;margin:0 10px 0 0 " />Please tick if you do not wish to receive further information from us</p>
On the backend .cs page which does all the processing I have:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Net.Mail;
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 Yucca.Pentire.Dal;
using Yucca.Pentire.Utils;
public partial class contact : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Master.UpdateBodyTag("contactus");
Master.UpdateMetaDetails("contact");
PhoneTracking.ImageSwap();
phonenumber.Text = PhoneTracking.HeaderPhone;
submitbutton.Click += new ImageClickEventHandler(submitbutton_Click);
}
void submitbutton_Click(object sender, ImageClickEventArgs e)
{
if (ValdiateAllFields())
{
MailMessage msg = new MailMessage();
SmtpClient smtp = Smtp.CreateSMTP(1);
//CheckBox brochure = (CheckBox) PreviousPage.FindControl("brochure");
string strBody;
strBody = "<strong>Name: </strong>" + name.Value + "<br />";
strBody += "<strong>Email: </strong>" + email.Value + "<br />";
strBody += "<strong>Telephone: </strong>" + telephone.Value + "<br />";
strBody += "<strong>Address: </strong>" + address1.Value + "<br />";
strBody += "<strong>Address: </strong>" + address2.Value + "<br />";
strBody += "<strong>Address: </strong>" + address3.Value + "<br />";
strBody += "<strong>Address: </strong>" + towncity.Value + "<br />";
strBody += "<strong>Address: </strong>" + county.Value + "<br />";
strBody += "<strong>Address: </strong>" + postcode.Value + "<br /><br />";
strBody += "<strong>Comments: </strong>" + comments.Value + "<br /><br />";
//strBody += "<strong>Brochure: </strong>" + brochure.Value + "<br /><br />";
// strBody += "<strong>Further Info: </strong>" + furtherInfo.Value + "<br /><br />";
//msg.From = new MailAddress("bookings@pentirehaven.co.uk");
//msg.To.Add(new MailAddress("bookings@pentirehaven.co.uk"));
msg.To.Add(new MailAddress("leannetempest@yahoo.co.uk"));
msg.Subject = "Enquiry";
msg.Body = strBody;
msg.IsBodyHtml = true;
smtp.Send(msg);
headersentmessage.Visible = true;
Response.Redirect("~/contact_amended.aspx");
}
}
This works unless I uncomment out the lines of code relating to the two new checkboxes and I get the error message:
CS0103: The name 'brochure' does not exist in the current context
Can anyone help? Many thanks...