Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts

    ASP Form submission Page Not grabbing All Information

    Hello, Im creating a page in ASP with javascript (which grabs form details) 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:

    Code:
    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;
            mp.activateNav("contact");
        }
    
        protected void emailForm(object sender, EventArgs e)
        {
            SmtpClient mailer = new SmtpClient();
            MailMessage msg = new MailMessage();
    
         	msg.To.Add(new MailAddress("test@test.com", "Test")); //Test account
    
            msg.From = new MailAddress("test@test.com", "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("");
                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:

    Code:
    <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
                    </span>
                    
                    <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>
    </select>
    <br/>
    
    <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>
    </select>
    
                    </span>
                    
                    <!-- <div class="clear spacer"></div> -->
                    <br/>
                    <p><em>* Indicates required field</em></p>
                    <input type="submit" value="Submit" runat="server" onserverclick="emailForm" onClick="return validate(event);" />
    </form>
    Is there a way to have this submit WITH the check boxes and selected items in the drop down menu??

    -Aaron

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,979
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Yes, don't use <input> or <select>.

    Instead, use the ASP.NET equivalents:
    Code:
    <asp:CheckBox id="learnAdvertisement" runat="server"
                  Text="&nbsp;Advertisementid" TextAlign="Right"
                  AutoPostBack="False"
    />
    
    <asp:DropDownList id="learnPring" runat="server">
    <asp:ListItem value="independentbank">Choose One</asp:ListItem>
    <asp:ListItem value="independentbank">Independent Banker</asp:ListItem>
    <asp:ListItem value="creditunionmag">Credit Union Magazine</asp:ListItem>
    ...
    </asp:DropDownList>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    That allowed the list to populate, but when I submitted the form it didnt show the options in the drop down list. Do you know why the chosen option in the drop down wouldnt show up in the submitted email? I tried to adjust it myself but then got compilation errors. With the edits you suggested, it seems that the code-behind .cs file needs to be changed too, Im just not sure what.

    For reference, I think the error occurs at the following part:

    Code:
            if (learnPrint.Checked || learnDigital.Checked || learnAdvertisement.Checked || learnTrade.Checked || learnMail.Checked || learnReferral.Checked)
            {
                returnValue.AppendLine("How did they learn about Insuritas?: ");
                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");
    			
    		}
    Is there something above that says "if DROPDOWN" or something, which allows the form to populate the email with what was chosen in the drop down menu?
    Last edited by aaronrusso; 02-19-2013 at 07:16 PM.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,979
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Quite frankly, I don't see why the page compiles, at all.
    Code:
    <input type="checkbox" id="learnPrint" runat="server"/>&nbsp;Print          
    <select id="learnPrint" name="Print">
    If you converted both of those to ASP.NET controls:
    Code:
    <asp:CheckBox id="learnPrint" runat="server"
                  Text="&nbsp;Print" TextAlign="Right"
                  AutoPostBack="False"
    />
    
    <asp:DropDownList id="learnPrint" runat="server">
    Then ASP.NET should have barfed on your feet because you have two controls with the same id!

    The id's MUST be UNIQUE on a page (both in HTML and in ASP.NET).
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Love the graphic explanation Regardless, I did use two unique IDs (the first was learnPrintBox and the other was learnPrint). Code is now set up like this:

    Code:
    <asp:CheckBox ID="learnAdvertisement" runat="server" Text="Advertisement" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnTrade" runat="server" Text="Trade&nbsp;Show" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnMail" runat="server" Text="Direct&nbsp;Mail" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnReferral" runat="server" Text="Referral" TextAlign="left" AutoPostBack="false"/>
    <asp:CheckBox ID="learnPrintBox" runat="server" Text="Print" TextAlign="left" AutoPostBack="false"/>
    <asp:DropDownList ID="learnPrint" runat="server">
    <asp:ListItem value="choose">Choose One</asp:ListItem>
    <asp:ListItem value="independentbank">Independent Banker</asp:ListItem>
    <asp:ListItem value="creditunionmag">Credit Union Magazine</asp:ListItem>
    <asp:ListItem value="creditunionjournal">Credit Union Journal </asp:ListItem>
    <asp:ListItem value="creditunionbus">Credit Union Business</asp:ListItem>
    <asp:ListItem value="credituniontimes">Credit Union Times</asp:ListItem>
    <asp:ListItem value="nafcu">NAFCU</asp:ListItem>
    <asp:ListItem value="callahan">Callahan & Associates</asp:ListItem>
    <asp:ListItem value="bankinsur">Bank Insurance & Securities Marketing</asp:ListItem>
    </asp:DropDownList>
    
    <asp:CheckBox ID="learnDigitalBox" runat="server" Text="Digital" TextAlign="left" AutoPostBack="false"/>
    <asp:DropDownList ID="learnDigital" runat="server">
    <asp:ListItem value="choose">Choose One</asp:ListItem>
    <asp:ListItem value="independentbank">Independent Banker</asp:ListItem>
    <asp:ListItem value="creditunionmag">Credit Union Magazine</asp:ListItem>
    <asp:ListItem value="creditunionjournal">Credit Union Journal </asp:ListItem>
    <asp:ListItem value="creditunionbus">Credit Union Business</asp:ListItem>
    <asp:ListItem value="credituniontimes">Credit Union Times</asp:ListItem>
    <asp:ListItem value="nafcu">NAFCU</asp:ListItem>
    <asp:ListItem value="callahan">Callahan & Associates</asp:ListItem>
    <asp:ListItem value="bankinsur">Bank Insurance & Securities Marketing</asp:ListItem>
    </asp:DropDownList>
    So there should be two drop downs with check boxes next to them, and when you hit submit on the page, it should populate what was checked AND chosen in the drop down, and show up on the email sent. It doesnt. With the above code being used, it does compile, but the options are just not showing up when selected and submitted.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,979
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Man, I haven't messed with ASP.NET in over a year.

    What you show there sure looks right. I'd have to run an experiment to see what, if anything is wrong. If I get the time, I will.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New Coder
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    No problem, its not super pressing although important. Thanks for the help so far though!

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,979
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Well, I dunno what you are doing wrong in your backend code, but it all works fine for me.

    Here's my default.aspx page:
    Code:
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
    <asp:CheckBox ID="learnAdvertisement" runat="server" Text="Advertisement" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnTrade" runat="server" Text="Trade&nbsp;Show" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnMail" runat="server" Text="Direct&nbsp;Mail" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnReferral" runat="server" Text="Referral" TextAlign="left" AutoPostBack="false"/>
    <asp:CheckBox ID="learnPrintBox" runat="server" Text="Print" TextAlign="left" AutoPostBack="false"/>
    <asp:DropDownList ID="learnPrint" runat="server">
    <asp:ListItem value="choose">Choose One</asp:ListItem>
    <asp:ListItem value="independentbank">Independent Banker</asp:ListItem>
    <asp:ListItem value="creditunionmag">Credit Union Magazine</asp:ListItem>
    <asp:ListItem value="creditunionjournal">Credit Union Journal </asp:ListItem>
    <asp:ListItem value="creditunionbus">Credit Union Business</asp:ListItem>
    <asp:ListItem value="credituniontimes">Credit Union Times</asp:ListItem>
    <asp:ListItem value="nafcu">NAFCU</asp:ListItem>
    <asp:ListItem value="callahan">Callahan & Associates</asp:ListItem>
    <asp:ListItem value="bankinsur">Bank Insurance & Securities Marketing</asp:ListItem>
    </asp:DropDownList>
    <hr />
    <asp:CheckBox ID="learnDigitalBox" runat="server" Text="Digital" TextAlign="left" AutoPostBack="false"/>
    <asp:DropDownList ID="learnDigital" runat="server">
    <asp:ListItem value="choose">Choose One</asp:ListItem>
    <asp:ListItem value="independentbank">Independent Banker</asp:ListItem>
    <asp:ListItem value="creditunionmag">Credit Union Magazine</asp:ListItem>
    <asp:ListItem value="creditunionjournal">Credit Union Journal </asp:ListItem>
    <asp:ListItem value="creditunionbus">Credit Union Business</asp:ListItem>
    <asp:ListItem value="credituniontimes">Credit Union Times</asp:ListItem>
    <asp:ListItem value="nafcu">NAFCU</asp:ListItem>
    <asp:ListItem value="callahan">Callahan & Associates</asp:ListItem>
    <asp:ListItem value="bankinsur">Bank Insurance & Securities Marketing</asp:ListItem>
    </asp:DropDownList> 
    <hr />  &nbsp;
            <asp:Button ID="Button1" runat="server" Text="Submit" />
            <hr />
            <asp:TextBox ID="TextBox1" runat="server" Columns="50" Rows="10" TextMode="MultiLine"></asp:TextBox></div>
        </form>
    </body>
    </html>
    And here is the default.aspx.vb page:
    Code:
    Partial Class _Default
        Inherits System.Web.UI.Page
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            TextBox1.Text = "learnAdvertisement? " & learnAdvertisement.Checked & vbNewLine _
                          & "learnPrintBox? " & learnPrintBox.Checked & vbNewLine _
                          & "learnPrint : " & learnPrint.Text & vbNewLine _
                          & "learnDigitalBox? " & learnDigitalBox.Checked & vbNewLine _
                          & "learnDigital : " & learnDigital.Text
    
        End Sub
    End Class
    I didn't dump out the state of all the check boxes, but enough to prove the concept.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,979
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Well, shoot, looking again at your code, NO PLACE are you even *TRYING* to get the .Text of the two drop downs!

    See my code example:
    Code:
            TextBox1.Text = "learnAdvertisement? " & learnAdvertisement.Checked & vbNewLine _
                          & "learnPrintBox? " & learnPrintBox.Checked & vbNewLine _
                          & "learnPrint : " & learnPrint.Text & vbNewLine _
                          & "learnDigitalBox? " & learnDigitalBox.Checked & vbNewLine _
                          & "learnDigital : " & learnDigital.Text
    Those two in red are getting the selected value of the two dropdowns!
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    New Coder
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Im not sure what you are doing, but Im not using VB to write this. Here is the entire code behind file, named contactus.aspx.cs:

    Code:
    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;
            mp.activateNav("contact");
        }
    
        protected void emailForm(object sender, EventArgs e)
        {
            SmtpClient mailer = new SmtpClient();
            MailMessage msg = new MailMessage();
    
          	msg.To.Add(new MailAddress("test@test.com", "To Test")); //Test account
    
            msg.From = new MailAddress("test2@test.com", "From Test2"); //Test account
            msg.Subject = "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("");
                returnValue.AppendLine("Their question or request is: " + question.Value);
            }
    
            if (learnPrint.Checked || learnAdvertisement.Checked || learnTrade.Checked || learnMail.Checked || learnReferral.Checked || learnDigital.Checked)
            {
                returnValue.AppendLine("How did they learn about Insuritas?: ");
                //if (learnWeb.Checked) returnValue.AppendLine("  Web Search");
                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;
        }
    
    
    }
    As you can see, there are no places calling "text" or anything of the sort. The above code works with the form and allows the check boxes chosen to show up in the email. Using the above code however, I am trying to get drop down values to also show up in the email.

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,979
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Quote Originally Posted by aaronrusso View Post
    Im not sure what you are doing, but Im not using VB to write this.
    Not a big deal Trivial to change that tiny bit of code that I had in VB to C#.

    As you can see, there are no places calling "text" or anything of the sort.
    Yes. And that's your problem.

    If you want to get the value of a dropdown list, you need to use
    Code:
    IDofDropDown.Text
    TRY IT!

    Code:
        private string getBody()
        {
            StringBuilder returnValue = new StringBuilder();
    
            ... all the other returnValue stuff ...
    
            returnValue.AppendLine("learnPrint : " + learnPrint.Text);
            returnValue.AppendLine("learnDigital : " + learnDigital.Text);
    
            return returnValue.ToString();
        }
    I gather you didn't write this code yourself? Cloned or copied it from somewhere?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    aaronrusso (02-20-2013)

  • #12
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,979
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Here. In C# code:
    Code:
    <%@ Page Language="C#" AutoEventWireup="false"  %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox1.Text = "learnAdvertisement? " + learnAdvertisement.Checked + "\n"
                          + "learnPrintBox? " + learnPrintBox.Checked + "\n"
                          + "learnPrint: " + learnPrint.Text + "\n"
                          + "learnDigitalBox? " + learnDigitalBox.Checked + "\n"
                          + "learnDigital: " + learnDigital.Text;
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
    <asp:CheckBox ID="learnAdvertisement" runat="server" Text="Advertisement" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnTrade" runat="server" Text="Trade&nbsp;Show" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnMail" runat="server" Text="Direct&nbsp;Mail" TextAlign="left" AutoPostBack="false"/>
                    <asp:CheckBox ID="learnReferral" runat="server" Text="Referral" TextAlign="left" AutoPostBack="false"/>
    <asp:CheckBox ID="learnPrintBox" runat="server" Text="Print" TextAlign="left" AutoPostBack="false"/>
    <asp:DropDownList ID="learnPrint" runat="server">
    <asp:ListItem value="choose">Choose One</asp:ListItem>
    <asp:ListItem value="independentbank">Independent Banker</asp:ListItem>
    <asp:ListItem value="creditunionmag">Credit Union Magazine</asp:ListItem>
    <asp:ListItem value="creditunionjournal">Credit Union Journal </asp:ListItem>
    <asp:ListItem value="creditunionbus">Credit Union Business</asp:ListItem>
    <asp:ListItem value="credituniontimes">Credit Union Times</asp:ListItem>
    <asp:ListItem value="nafcu">NAFCU</asp:ListItem>
    <asp:ListItem value="callahan">Callahan & Associates</asp:ListItem>
    <asp:ListItem value="bankinsur">Bank Insurance & Securities Marketing</asp:ListItem>
    </asp:DropDownList>
    <hr />
    <asp:CheckBox ID="learnDigitalBox" runat="server" Text="Digital" TextAlign="left" AutoPostBack="false"/>
    <asp:DropDownList ID="learnDigital" runat="server">
    <asp:ListItem value="choose">Choose One</asp:ListItem>
    <asp:ListItem value="independentbank">Independent Banker</asp:ListItem>
    <asp:ListItem value="creditunionmag">Credit Union Magazine</asp:ListItem>
    <asp:ListItem value="creditunionjournal">Credit Union Journal </asp:ListItem>
    <asp:ListItem value="creditunionbus">Credit Union Business</asp:ListItem>
    <asp:ListItem value="credituniontimes">Credit Union Times</asp:ListItem>
    <asp:ListItem value="nafcu">NAFCU</asp:ListItem>
    <asp:ListItem value="callahan">Callahan & Associates</asp:ListItem>
    <asp:ListItem value="bankinsur">Bank Insurance & Securities Marketing</asp:ListItem>
    </asp:DropDownList> 
    <hr />  &nbsp;
            <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
            <hr />
            <asp:TextBox ID="TextBox1" runat="server" Columns="50" Rows="10" TextMode="MultiLine"></asp:TextBox></div>
        </form>
    </body>
    </html>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    aaronrusso (02-20-2013)

  • #13
    New Coder
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Finally got it to work! Thanks. I had to jerry-rig a combination of asp form data and html input/label fields for it to work with the current code-behind file though. No I didnt make the form, some "professional" web company made it and left as I came into the company. Id make a new one but the company doesnt want to change it for some reason. Oh well... thanks again!


  •  

    Posting Permissions

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