Hi,
I am creating a Feedack form Using Text Box, Dropdownlist and Check box list
<table runat="server" id="FormTable" align="center" class="style1">
<tr>
<td>
Name</td>
<td>
:-</td>
<td>
<asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Age</td>
<td>
:-</td>
<td>
<asp:DropDownList ID="AgeDropDownList" runat="server">
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>22</asp:ListItem>
<asp:ListItem>24</asp:ListItem>
<asp:ListItem>26</asp:ListItem>
<asp:ListItem>28</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
<asp:ListItem>32</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Subject</td>
<td>
:-</td>
<td>
<asp:TextBox ID="SubjectTextBox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
Profession</td>
<td class="style3">
:-</td>
<td class="style3">
<asp:CheckBoxList ID="ProfessionCheckBoxList" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem>Student</asp:ListItem>
<asp:ListItem>Accountant</asp:ListItem>
<asp:ListItem>Engineer</asp:ListItem>
<asp:ListItem>Operator</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style2">
</td>
<td class="style2">
<asp:Button ID="SendButton" runat="server" Text="Send"
onclick="SendButton_Click" />
</td>
</tr>
</table>
Coding of .aspx.css File
protected void SendButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string fileName = Server.MapPath("~/App_Data/Contact.txt");
string mailBody = System.IO.File.ReadAllText(fileName);
mailBody = mailBody.Replace("##Name##", NameTextBox.Text);
mailBody = mailBody.Replace("##Age##", AgeDropDownList.SelectedValue);
mailBody = mailBody.Replace("##Subject##", SubjectTextBox.Text);
mailBody = mailBody.Replace("##Profession##", ProfessionCheckBoxList.Text);
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Response from web site";
myMessage.Body = mailBody;
myMessage.From = new MailAddress("
[email protected]", "Abhishek Kumar");
myMessage.To.Add(new MailAddress("
[email protected]", "Abhishek Kumar"));
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMessage);
lblMessage.Visible = true;
FormTable.Visible = false;
}
}
}
My problem is that when the user tick More than one check box only the text of first check box
show in the mail and remaining 2nd and third check box text ignored.