lundi 17 décembre 2018

How can I display the checked boxes of an email form in my email body message?

I'm trying to create a contact us form. I've got a few text input fields, drop down menus, and check boxes. When troubleshooting, I am able to pull the text from the textbox inputs and drop down menus. Unfortunately my code breaks when trying to get the values from my check boxes added to the email body message. How can I include the boxes with the "checked" value in my email body when the form is submitted? Below is an example code. Thank you for the help.

<head>
msg.Subject = "Test Form";
    msg.Body = "\n Name: " + txtname.Text + Environment.NewLine + "\n Color: " + color.Text + Environment.NewLine + "\n Shape " + shape.Value;
</head>    
<body>
<asp:TextBox AlternateText="Name Field" id="txtname" runat="server" 
        MaxLength="32" placeholder="Name" alt="Name*" type="text" > 
        </asp:TextBox>
        <asp:DropDownList id="color" runat="server" AlternateText="Color Field" 
        placeholder="Color" alt="Color Field" type="text" >
              <asp:ListItem Text="Blue" Value="blue" />
              <asp:ListItem Text="Red" Value="red" />
              <asp:ListItem Text="White" Value="white" />
            </asp:DropDownList>
<fieldset>        
        <label for="circle">Circle<input type="checkbox" name="shape" id="circle">
        </label>
        <label for="square">Square<input type="checkbox" name="shape" id="square">
        </label>
        <label for="triangle">Triangle<input type="checkbox" name="shape" id="triangle">
        </label>
</fieldset>
</body>




Aucun commentaire:

Enregistrer un commentaire