Results 1 to 1 of 1

Thread: ASP Form submission Page Not grabbing All Information

  1. #1
    Join Date
    Sep 2009
    Thanked 0 Times in 0 Posts

    Exclamation ASP Form submission Page Not grabbing All Information

    Hello, Im creating a page in ASP for an insurance company contact form and the form doesnt seem to be grabbing ALL the information and sending it to an email. It successfully sends all the information to the test email upon submission EXCEPT for the drop down menu options towards the bottom. All it shows in the email is the check boxed options and not what was selected in the drop down menu WITH the check boxes (towards the bottom). Below is the code behind the page currently:

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Text;
    using System.Net.Mail;
    public partial class contactus : System.Web.UI.Page
        string _devServerList = ConfigurationSettings.AppSettings["devHosts"];
        protected void Page_Load(object sender, EventArgs e)
            site mp = (site)this.Master;
        protected void emailForm(object sender, EventArgs e)
            SmtpClient mailer = new SmtpClient();
            MailMessage msg = new MailMessage();
         	msg.To.Add(new MailAddress("", "Test")); //Test account
            msg.From = new MailAddress("", "Contact Request Test"); //Test Account
            msg.Subject = "Company Contact Form Request";
            msg.IsBodyHtml = false;
            msg.Body = getBody();
            if (!isOnDevServer()) mailer.Send(msg);
            mailer = null;
            contactForm.Visible = false;
            contactTY.Visible = true;
        private string getBody()
            StringBuilder returnValue = new StringBuilder();
            if (clientYes.Checked) returnValue.AppendLine("Existing Client: Yes");
            if (clientNo.Checked) returnValue.AppendLine("Existing Client: No");
            if (name.Value != "") returnValue.AppendLine("Name: " + name.Value);
            if (title.Value != "") returnValue.AppendLine("Title: " + title.Value);
            if (companyName.Value != "") returnValue.AppendLine("Company/Institution Name: " + companyName.Value);
            if (address.Value != "") returnValue.AppendLine("Address: " + address.Value);
            if (city.Value != "") returnValue.AppendLine("City: " + city.Value);
            if (state.Value != "") returnValue.AppendLine("State: " + state.Value);
            if (zipCode.Value != "") returnValue.AppendLine("Zip Code: " + zipCode.Value);
            if (email.Value != "") returnValue.AppendLine("Email Address: " + email.Value);
            if (phone.Value != "") returnValue.AppendLine("Phone: " + phone.Value);
            if (question.Value != "")
                returnValue.AppendLine("Their question or request is: " + question.Value);
            if (learnAdvertisement.Checked || learnTrade.Checked || learnMail.Checked || learnReferral.Checked || learnPrint.Checked || learnDigital.Checked )
                returnValue.AppendLine("How did they learn about Us?: ");
                if (learnAdvertisement.Checked) returnValue.AppendLine("  Advertisement");
                if (learnTrade.Checked) returnValue.AppendLine("  Trade Show");
                if (learnMail.Checked) returnValue.AppendLine("  Direct Mail");
                if (learnReferral.Checked) returnValue.AppendLine("  Referral");
    	    if (learnPrint.Checked) returnValue.AppendLine(" Print");
    	    if (learnDigital.Checked) returnValue.AppendLine(" Digital");
            return returnValue.ToString();
        public bool isOnDevServer()
            if (_devServerList.IndexOf(",") > 0)
                foreach (string r in _devServerList.Split(",".ToCharArray()))
                    if (Request.Url.Host.ToString() == r) return true;
            else if (_devServerList.Length > 0)
                if (Request.Url.Host.ToString() == _devServerList) return true;
            return false;
    And the HTML on the aspx page is the following:

                    <form runat="server">
                    <span class="radio">
                    <label>Are You an Existing Client?</label>
                    <input type="radio" id="clientYes" runat="server" />Yes
                    <input type="radio" id="clientNo" runat="server" />No
                    <label for="name">Name: *</label>
                    <input type="text" id="name" runat="server" />	 	
                    <label for="title">Title: *</label>
                    <input type="text" id="title" runat="server" />
                    <label for="companyName">Institution/Company Name: *</label>
                    <input type="text" id="companyName" runat="server" />
    				<label for="address">Address:</label>
                    <input type="text" id="address" runat="server" />
    				<!-- </div> 
                    <div class="left">-->
                    <label for="city">City:</label>
                    <input type="text" id="city" runat="server" style="width: 100px; margin-right: 5px;" />
                    <!-- </div>
                    <div class="left"> -->
                    <label for="state">State:</label>
                    <input type="text" id="state" runat="server" style="width: 40px; margin-right: 5px;" />
                    <!-- </div>
                    <div class="left"> -->
                    <label for="zipCode">Zip:</label>
                    <input type="text" id="zipCode" runat="server" style="width: 80px;" />
                   <!--  </div>
                    <div class="clear spacer"></div> -->
                    <label for="email">Email Address: *</label>	 
                    <input type="text" id="email" runat="server" />
                    <label for="phone">Phone:</label>
                    <input type="text" id="phone" runat="server" />
                    <label for="additionalinfo">What is your question or request? *</label>
                    <textarea id="question" rows="6" cols="50" runat="server"></textarea>
                   <!-- <div class="clear spacer"></div>	-->
                  <label>How did you initially learn about Us?</label>
                    <span class="radio">
                    <input type="checkbox" id="learnAdvertisement" runat="server" />&nbsp;Advertisement
                    <input type="checkbox" id="learnTrade" runat="server" />&nbsp;Trade Show
                    <input type="checkbox" id="learnMail" runat="server" />&nbsp;Direct Mail
                    <input type="checkbox" id="learnReferral" runat="server" />&nbsp;Referral<br/>
    <input type="checkbox" id="learnPrint" runat="server"/>&nbsp;Print          
    <select id="learnPrint" name="Print">
    <option value="independentbank">Choose One </option>
    <option value="independentbank">Independent Banker </option>
    <option value="creditunionmag">Credit Union Magazine</option>
    <option value="creditunionjournal">Credit Union Journal </option>
    <option value="creditunionbus">Credit Union Business</option>
    <option value="credituniontimes">Credit Union Times</option>
    <option value="nafcu">NAFCU</option>
    <option value="callahan">Callahan & Associates</option>
    <option value="bankinsur">Bank Insurance & Securities Marketing</option>
    <input type="checkbox" id="learnDigital" runat="server"/>&nbsp;Digital
    <select id="learnDigital" name="Digital">
    <option value="independentbank2">Choose One </option>
    <option value="independentbank2">Independent Banker </option>
    <option value="creditunionmag2">Credit Union Magazine</option>
    <option value="creditunionjournal2">Credit Union Journal </option>
    <option value="creditunionbus2">Credit Union Business</option>
    <option value="credituniontimes2">Credit Union Times</option>
    <option value="nafcu2">NAFCU</option>
    <option value="callahan2">Callahan & Associates</option>
    <option value="bankinsur2">Bank Insurance & Securities Marketing</option>
                    <!-- <div class="clear spacer"></div> -->
                    <p><em>* Indicates required field</em></p>
                    <input type="submit" value="Submit" runat="server" onserverclick="emailForm" onClick="return validate(event);" />
    Is there a way to have this submit WITH the check boxes and selected items in the drop down menu??

    Last edited by aaronrusso; 02-14-2013 at 06:54 PM.

Similar Threads

  1. Auto Save Form Processing Previous Form Submission
    By Meleo in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 07-09-2012, 04:38 AM
  2. Story submission form with formatted preview page
    By mykstor in forum Looking for such a script or service
    Replies: 0
    Last Post: 05-09-2009, 05:09 PM
  3. grabbing all form data
    By ATMA in forum JavaScript
    Replies: 17
    Last Post: 11-06-2007, 06:08 PM
  4. form submission
    By boch2691 in forum JavaScript
    Replies: 5
    Last Post: 05-02-2007, 12:30 PM
  5. Replies: 2
    Last Post: 02-08-2007, 09:12 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts