locked
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.

    Code:

    <!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))
               {
                InfoChange.Append(listItem.Text);
               }
               
               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");

    try
    {
    msg = new MailMessage("from email address", 
    "to email address", "Excavator Information Changes", 
    sb.ToString());

    sc.Send(msg);
    MultiView1.SetActiveView(viewconfirm);
    }
    catch(Exception ex)
    {

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

    }
    finally
    {

    if (msg != null)
    {
    msg.Dispose();
    }
     
    }



    }


    protected void Page_Load(object sender, EventArgs e)
    {

    if(!IsPostBack)
    {
    MultiView1.SetActiveView(viewform);
    }

    }
    </script>

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

    <head>
    <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" />
    </head>

    <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>
    <fieldset>
    <ul>
    <li>
    <asp:Image id="Image1" runat="server" ImageUrl="mole.jpg" ImageAlign="Right" />
    <li>
    <li>
    <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>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox id="txtTicket" runat="server" Font-Names="Calibri" Width="240px"></asp:TextBox>
    </li>
    <br />
    <br />
    <li>
    <asp:Label id="lblChanges" runat="server" Font-Bold="True" Font-Names="Calibri" Font-Size="Medium" Text="What information has changed?"></asp:Label>
    &nbsp;
    <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:CheckBoxList>
    <li>
    <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>
    </li>
    </li>
    </li>
    </li>
    </li>
    </li>
    </li>
    </li>
    </li>
    </li>
    </ul>
    </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>
    <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 />
    </asp:View>
    <br />
    <br />
    <br />
    </asp:MultiView>
    </div>
    </body>
    </form>

    </html>

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

Answers

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