CheckBoxList not working RRS feed

  • Question

  • Created a form for our intranet site using CheckBoxList and some code I received from a previous post. The code worked on the test server but not on the actually production site. Now I can't get the code to work at all. Any help would greatly be appreciated as I am still new at coding. Attached is the code and a screenshot of the for.


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Net.Mail" %>
    <%@ Import Namespace="System.Text" %>

    <script runat="server">

    protected void btnSubmit_Click(object sender, EventArgs e)

    SmtpClient sc = new SmtpClient("Mail Sever IP");
    StringBuilder sb = new StringBuilder();
               MailMessage msg = null;
               StringBuilder InfoChange = new StringBuilder();
               foreach (var ListItem in cbInfoChange.Items.OfType<ListItem>().Where(s => s.Selected))
               var _InfoChange = InfoChange.ToString();
               if(_InfoChange.Length <= 0)
                _InfoChange = "N/A";

    sb.Append("Agent Name:   " + txtName.Text + "\n");
    sb.Append("Ticket Number:   " + txtTicket.Text + "\n");
    sb.Append("What information has changed:  " + _InfoChange + "\n");
    sb.Append("Misspellings:  " + txtMisspelling.Text + "\n");

    msg = new MailMessage("from email address", 
    "to email address", "Excavator Information Changes", 

    catch(Exception ex)

    // something bad happened
    Response.Write("Something bad happened!");


    if (msg != null)


    protected void Page_Load(object sender, EventArgs e)



    <html xmlns="http://www.w3.org/1999/xhtml">

    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Excavator Information Change Form</title>
    <link rel="stylesheet" href="form.css" />

    <form id="form1" runat="server">
    <body bgcolor="#D8D5AB">
    <div id="wrapper">

    <asp:MultiView id="MultiView1" runat="server">
    <asp:View id="viewform" runat="server">
    <h1>Excavator Information Changes</h1>
    <asp:Image id="Image1" runat="server" ImageUrl="mole.jpg" ImageAlign="Right" />
    <asp:Label id="lblName" runat="server" Font-Bold="True" Font-Names="Calibri" Font-Size="Medium" Text="Agent Name:"></asp:Label>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:TextBox id="txtName" runat="server" Font-Names="Calibri" Width="240px"></asp:TextBox>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
    <br />
    <li style="width: 540px">
    <asp:Label id="lblTicket" runat="server" Font-Bold="True" Font-Names="Calibri" Font-Size="Medium" Text="Ticket Number:"></asp:Label>
    <asp:TextBox id="txtTicket" runat="server" Font-Names="Calibri" Width="240px"></asp:TextBox>
    <br />
    <br />
    <asp:Label id="lblChanges" runat="server" Font-Bold="True" Font-Names="Calibri" Font-Size="Medium" Text="What information has changed?"></asp:Label>
    <asp:CheckBoxList id="cbInfoChange" runat="server" RepeatColumns="2" TextAlign="Left" Width="543px" CellPadding="2" CellSpacing="2">
    <asp:ListItem>Company Name</asp:ListItem>
    <asp:ListItem>Company Phone Number</asp:ListItem>
    <asp:ListItem>Company Mailing Address</asp:ListItem>
    <asp:ListItem>Caller Name</asp:ListItem>
    <asp:ListItem>Contact Name/Number</asp:ListItem>
    <asp:Label id="lblMisspelling" runat="server" Font-Bold="True" Font-Names="Calibri" Font-Size="Medium" Text="Any misspelling of:"></asp:Label>
    &nbsp;<asp:TextBox id="txtMisspelling" runat="server" Width="240px"></asp:TextBox>
    </fieldset> <fieldset>
    <asp:Button id="btnSubmit" runat="server" Font-Bold="True" Font-Names="Calibri" Font-Size="Medium" OnClick="btnSubmit_Click" Text="Submit" Width="85px" />
    </fieldset> <br />
    <br />

    <asp:View id="viewconfirm" runat="server">
    <p>Thank you for your submission.</p>
    <asp:Button id="btn_Close" runat="server" Font-Bold="True" Font-Names="Calibri" Font-Size="Large" Height="29px"  Text="Close" Width="89px" />
    <br /> <br />
    <br />
    <br />
    <br />


    • Moved by Eason_H Tuesday, October 29, 2013 6:05 AM
    Monday, October 28, 2013 3:08 PM


All replies

  • there is no way to tell what is wrong from your code. we need an error or trace of what is happening. Seehttp://www.c-sharpcorner.com/UploadFile/2f73dd/page-tracing-in-Asp-Net-4-0/

    You should also ask this question in the asp.net forums.

    Bob - www.crowcoder.com

    Monday, October 28, 2013 4:14 PM
  • Please post ASP.NET questions in the ASP.NET forums (http://forums.asp.net ).
    • Proposed as answer by Just Karl Tuesday, October 29, 2013 2:29 PM
    • Marked as answer by Just Karl Sunday, November 10, 2013 3:34 AM
    Monday, October 28, 2013 5:02 PM
  • Sorry, for posting in the wrong area. I have posted this to asp forum. 

    Here is a screenshot of the error though message.

    Again I apologize for mistake.

    Monday, October 28, 2013 6:06 PM
  • Hi ja_tom,

    This forum is to discuss problems of C# development.

    Since the issue regards ASP.NET and website deployment. I suggestion you post the question in the ASP.NET forums at http://forums.asp.net/. It is appropriate and more experts will assist you.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 29, 2013 6:05 AM