Error in C#--expected class, delegate, enum, interface, or struct

I am using Microsoft Visual C# to try to find isolate an error.  It is highlighting "void" in the first line, and the following error comes up:

Expected class, delegate, enum, interface, or struct

What does that mean and how can I fix it?
protected void status_SelectedIndexChanged(object sender, System.EventArgs e)
{
   
   if (statusAns.SelectedValue == "status_guest") {
        RequiredFieldValidator4.enabled = true;
   }
    else {
         RequiredFieldValidator4.enabled = false;
   }
    
 }
 
 
 Status:*<br /><asp:RadioButtonList id="status" 
            OnSelectedIndexChanged="status_SelectedIndexChanged"
            AutoPostBack="true"
            runat="server"/>
 
                               <asp:ListItem Value="undergraduate" />
                                <asp:ListItem Value="graduate" />
                                <asp:ListItem Value="fs" />
                                 <asp:ListItem Value="guest"/></asp:RadioButtonList>   
 
                                                                                                 <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="status"
                            ErrorMessage="Status" runat="Server" Text="*Status Required"></asp:RequiredFieldValidator><br />
                                                                                                                If you are a guest user, <br /> please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
 <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="school"
                            ErrorMessage="School Name" runat="Server" Text="*School Name Required"></asp:RequiredFieldValidator>
           
        <br />

Open in new window

jianxin9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Priest04Commented:
MOst probably you have placed the coud outsite of the class. This code must reside in some class.
0
jianxin9Author Commented:
I have placed the code at the bottom of my code behind--is it in the right place?  I'm confused about the class thing.  Thanks!
<%@ Page Language="c#" Debug="true"%>
 
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Net" %>
 
<script runat="server" language="C#">
		 
 
 
  void Page_Load()
  {
      if (Page.IsPostBack)
      {
          questionsPanel.Visible = false;
          Message.Visible = true;  
          int correct = 0;
          if (q1.SelectedIndex == 2) correct++;
          if (q2.SelectedIndex == 4) correct++;
          if (q3.SelectedIndex == 2) correct++;
          if (q4.SelectedIndex == 0) correct++;
          if (q5.SelectedIndex == 5) correct++;
          if (q6.SelectedIndex == 1) correct++;
          if (q7.SelectedIndex == 2) correct++;
 
          LoadConn(correct);
      }
      else
      {
          questionsPanel.Visible = true;
          Message.Visible = false;  
      }
  }
 
private void LoadConn(int score)
{
    int percent;
    percent = (score*100)/7;  
  
    // Create the objects 
    OleDbConnection conn;
    OleDbCommand comm;
    
    // Instance the connection open it
    conn = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source ="+ Server.MapPath("assessments.accdb")+";User Id=; Jet OLEDB:Database Password=;");
    conn.Open();
    
    // Create the insert SQL 
    string sSQL = "";
		string qname = "plagiarism"; 
    sSQL = "Insert into posttest_table(fname,lname,username,coursenum,emailId,emailId2,status,school,qname,answered,score,q1,q2,q3,q4,q5,q6,q7) values('" + fname.Text + "','" + lname.Text +"','" + portal_id.Text +"','"+course_id.Text+"','"+emailId.Text+"','"+emailId2.Text+"','"+(status.SelectedIndex+1)+"','"+ school.Text +"','"+(qname)+"',"+score+","+percent+","+(q1.SelectedIndex+1)+","+(q2.SelectedIndex+1)+","+(q3.SelectedIndex+1)+","+(q4.SelectedIndex+1)+","+(q5.SelectedIndex+1)+","+(q6.SelectedIndex+1)+","+(q7.SelectedIndex+1)+");";
   
    //  Response.Write(sSQL + "<br />");
    //  Response.End();
    //  return;
    
    // Create a command object from the connection
    comm = conn.CreateCommand ();
    comm.CommandText = sSQL;
    comm.CommandType = CommandType.Text;
 
    // Try the insert 
    try
    {
        comm.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Response.Write("Error During DB Update: " + ex.ToString());
    }
    
    
   
    conn.Close();
    // Inserting data into the database end
     
    // Create the email body text
/* String bodyInfo = fname.Text+" "+lname.Text+" has taken the exam.\n <br />"+fname.Text  +" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option 3)<br /> You Answered:  Option "+(q1.SelectedIndex+1)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option 5) <br />You Answered: Option "+(q2.SelectedIndex+1)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option 3) <br />You Answered: Option "+(q3.SelectedIndex+1)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option 1) <br />You Answered: Option "+(q4.SelectedIndex+1)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option 6) <br />You Answered: Option "+(q5.SelectedIndex+1)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option 2) <br />You Answered: Option "+(q6.SelectedIndex+1)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option 3) <br /> You Answered: Option "+(q7.SelectedIndex+1);*/
 
 String bodyInfo = fname.Text+" "+lname.Text+" is a/an "+status.Text+", and has taken the exam for the course "+course_id.Text+".\n <br />"+fname.Text+" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option c)<br /> You Answered:  Option "+Convert.ToChar(q1.SelectedIndex+97)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option e) <br />You Answered: Option "+Convert.ToChar(q2.SelectedIndex+97)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option c) <br />You Answered: Option "+Convert.ToChar(q3.SelectedIndex+97)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option a) <br />You Answered: Option "+Convert.ToChar(q4.SelectedIndex+97)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option f) <br />You Answered: Option "+Convert.ToChar(q5.SelectedIndex+97)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option b) <br />You Answered: Option "+Convert.ToChar(q6.SelectedIndex+97)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option c) <br /> You Answered: Option "+Convert.ToChar(q7.SelectedIndex+97);
 
 
    // Create SMTP client
    SmtpClient client = new SmtpClient("mail.twu.edu");
        
    // Create SMTP message
    MailMessage message = new MailMessage();
 
    // Set message properties 
    message.From = new MailAddress ("");
    message.To.Add("");
    message.CC.Add(emailId.Text);
   if (!string.IsNullOrEmpty(emailId2.Text))
    {
       message.CC.Add(emailId2.Text);
    }
    message.Body = bodyInfo;
    message.Subject = "Doing Research: Plagiarism Quiz Results";
    message.IsBodyHtml = true;
   
    try
        {
 
            // Send EMail
            client.Send(message);
        }
        catch (Exception ex)
        {
            // Do Nothing  
        }
				
 
    // Send the user to the Results page
    Response.Redirect("results.aspx?fname="+fname.Text+"&lname="+lname.Text+"&score="+percent+"&q1="+(q1.SelectedIndex)+"&q2="+(q2.SelectedIndex)+"&q3="+(q3.SelectedIndex)+"&q4="+(q4.SelectedIndex)+"&q5="+(q5.SelectedIndex)+"&q6="+(q6.SelectedIndex)+"&q7="+(q7.SelectedIndex));
 
}
 
 
protected void status_SelectedIndexChanged(object sender, System.EventArgs e)
{
   
   if (statusAns.SelectedValue == "status_guest") {
        RequiredFieldValidator4.enabled = true;
   }
    else {
         RequiredFieldValidator4.enabled = false;
   }
    
 }
 
 
 
 
 </script>

Open in new window

0
Priest04Commented:
I dont know what IDE are you using, but when you create a new aspx page, example Default.aspx, when you press a + sign before its name in solution explorer, a file called Default.aspx.cs will be shown. Double click on it to open the window, where you should put the code you have provided. You will see a class called _Default. The code must be placed inside the class.

public partial class _Default : System.Web.UI.Page 
{
    // your code
  
}

Open in new window

0
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

CtrlAltDlCommented:
It doesn't have to be in a code-behind.  Just remove the protected and private from your functions if you are using in-line code.  Since your code is already in scope you don't need access modifiers (private, protected, public, etc.).
0
jianxin9Author Commented:
Sorry--I am so confused about this class thing, so I would do something like the following?

<%@ Page Language="c#" Debug="true"%>
 
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Net" %>
 
<script runat="server" language="C#">
                 
 public partial class _Default : System.Web.UI.Page
{
<%@ Page Language="c#" Debug="true"%>
 
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Net" %>
 
<script runat="server" language="C#">
                 
 public partial class _Default : System.Web.UI.Page 
{
 
 
  void Page_Load()
  {
      if (Page.IsPostBack)
      {
          questionsPanel.Visible = false;
          Message.Visible = true;  
          int correct = 0;
          if (q1.SelectedIndex == 2) correct++;
          if (q2.SelectedIndex == 4) correct++;
          if (q3.SelectedIndex == 2) correct++;
          if (q4.SelectedIndex == 0) correct++;
          if (q5.SelectedIndex == 5) correct++;
          if (q6.SelectedIndex == 1) correct++;
          if (q7.SelectedIndex == 2) correct++;
 
          LoadConn(correct);
      }
      else
      {
          questionsPanel.Visible = true;
          Message.Visible = false;  
      }
  }
 
private void LoadConn(int score)
{
    int percent;
    percent = (score*100)/7;  
  
    // Create the objects 
    OleDbConnection conn;
    OleDbCommand comm;
    
    // Instance the connection open it
    conn = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source ="+ Server.MapPath("assessments.accdb")+";User Id=; Jet OLEDB:Database Password=;");
    conn.Open();
    
    // Create the insert SQL 
    string sSQL = "";
                string qname = "plagiarism"; 
    sSQL = "Insert into posttest_table(fname,lname,username,coursenum,emailId,emailId2,status,school,qname,answered,score,q1,q2,q3,q4,q5,q6,q7) values('" + fname.Text + "','" + lname.Text +"','" + portal_id.Text +"','"+course_id.Text+"','"+emailId.Text+"','"+emailId2.Text+"','"+(status.SelectedIndex+1)+"','"+ school.Text +"','"+(qname)+"',"+score+","+percent+","+(q1.SelectedIndex+1)+","+(q2.SelectedIndex+1)+","+(q3.SelectedIndex+1)+","+(q4.SelectedIndex+1)+","+(q5.SelectedIndex+1)+","+(q6.SelectedIndex+1)+","+(q7.SelectedIndex+1)+");";
   
    //  Response.Write(sSQL + "<br />");
    //  Response.End();
    //  return;
    
    // Create a command object from the connection
    comm = conn.CreateCommand ();
    comm.CommandText = sSQL;
    comm.CommandType = CommandType.Text;
 
    // Try the insert 
    try
    {
        comm.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Response.Write("Error During DB Update: " + ex.ToString());
    }
    
    
   
    conn.Close();
    // Inserting data into the database end
     
    // Create the email body text
/* String bodyInfo = fname.Text+" "+lname.Text+" has taken the exam.\n <br />"+fname.Text  +" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option 3)<br /> You Answered:  Option "+(q1.SelectedIndex+1)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option 5) <br />You Answered: Option "+(q2.SelectedIndex+1)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option 3) <br />You Answered: Option "+(q3.SelectedIndex+1)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option 1) <br />You Answered: Option "+(q4.SelectedIndex+1)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option 6) <br />You Answered: Option "+(q5.SelectedIndex+1)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option 2) <br />You Answered: Option "+(q6.SelectedIndex+1)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option 3) <br /> You Answered: Option "+(q7.SelectedIndex+1);*/
 
 String bodyInfo = fname.Text+" "+lname.Text+" is a/an "+status.Text+", and has taken the exam for the course "+course_id.Text+".\n <br />"+fname.Text+" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option c)<br /> You Answered:  Option "+Convert.ToChar(q1.SelectedIndex+97)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option e) <br />You Answered: Option "+Convert.ToChar(q2.SelectedIndex+97)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option c) <br />You Answered: Option "+Convert.ToChar(q3.SelectedIndex+97)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option a) <br />You Answered: Option "+Convert.ToChar(q4.SelectedIndex+97)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option f) <br />You Answered: Option "+Convert.ToChar(q5.SelectedIndex+97)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option b) <br />You Answered: Option "+Convert.ToChar(q6.SelectedIndex+97)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option c) <br /> You Answered: Option "+Convert.ToChar(q7.SelectedIndex+97);
 
 
    // Create SMTP client
    SmtpClient client = new SmtpClient("mail.twu.edu");
        
    // Create SMTP message
    MailMessage message = new MailMessage();
 
    // Set message properties 
    message.From = new MailAddress ("");
    message.To.Add("");
    message.CC.Add(emailId.Text);
   if (!string.IsNullOrEmpty(emailId2.Text))
    {
       message.CC.Add(emailId2.Text);
    }
    message.Body = bodyInfo;
    message.Subject = "Doing Research: Plagiarism Quiz Results";
    message.IsBodyHtml = true;
   
    try
        {
 
            // Send EMail
            client.Send(message);
        }
        catch (Exception ex)
        {
            // Do Nothing  
        }
                                
 
    // Send the user to the Results page
    Response.Redirect("results.aspx?fname="+fname.Text+"&lname="+lname.Text+"&score="+percent+"&q1="+(q1.SelectedIndex)+"&q2="+(q2.SelectedIndex)+"&q3="+(q3.SelectedIndex)+"&q4="+(q4.SelectedIndex)+"&q5="+(q5.SelectedIndex)+"&q6="+(q6.SelectedIndex)+"&q7="+(q7.SelectedIndex));
 
}
 
 
protected void status_SelectedIndexChanged(object sender, System.EventArgs e)
{
   
   if (statusAns.SelectedValue == "status_guest") {
        RequiredFieldValidator4.enabled = true;
   }
    else {
         RequiredFieldValidator4.enabled = false;
   }
    
 }
 
 
 
 
 </script>

Open in new window

0
Priest04Commented:
What IDE are you using?
0
CtrlAltDlCommented:
I would just put it back in-line and follow my previous post.

Your code-behind should be something like:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace myProjectName
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jianxin9Author Commented:
I am using MIcrosoft Visual C# 2008 Express Edition.  Everything I have currently works just fine--it's only when I add in that that one piece of code where I get problems.  
0
jianxin9Author Commented:
Thanks for posting as well CtrlAltDl--but I am confused sorry--are you saying that I just need to remove "protected" from this code here?

protected void status_SelectedIndexChanged(object sender, System.EventArgs e)
{
   
   if (statusAns.SelectedValue == "status_guest") {
        RequiredFieldValidator4.enabled = true;
   }
    else {
         RequiredFieldValidator4.enabled = false;
   }
0
CtrlAltDlCommented:
yes, if it is in-line, like your original post.
0
Priest04Commented:
That will work, but what I would suggest is not to use inline code, since MS have provided a separate class just for the purpose to organize our code better. Look at the above post and try to locate the cs file I am talking about.

Just an advice so your code would look better.
0
CtrlAltDlCommented:
In-Line and Code-Behind, which is better?  It depends, but in your case you may want to just get this page working, so I would just modify your original in-line code.

Here is a small example of in-line and code-behind which is better debate:
http://discuss.joelonsoftware.com/default.asp?dotnet.12.597848.8

You really should learn about the advantages of both before you continue developing in .Net.

Here is a basic example of the two differences:
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/pages/codebehind.aspx
0
jianxin9Author Commented:
Thanks to both of you for the info.  I will definitely look over the advantages and disadvantages of both options.  But if I were to to do as in-line code, it should look like the following?  The piece of code I added is near the very bottom.
<%@ Page Language="c#" Debug="true"%>
 
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Net" %>
 
<script runat="server" language="C#">
		 
 
 
  void Page_Load()
  {
      if (Page.IsPostBack)
      {
          questionsPanel.Visible = false;
          Message.Visible = true;  
          int correct = 0;
          if (q1.SelectedIndex == 2) correct++;
          if (q2.SelectedIndex == 4) correct++;
          if (q3.SelectedIndex == 2) correct++;
          if (q4.SelectedIndex == 0) correct++;
          if (q5.SelectedIndex == 5) correct++;
          if (q6.SelectedIndex == 1) correct++;
          if (q7.SelectedIndex == 2) correct++;
 
          LoadConn(correct);
      }
      else
      {
          questionsPanel.Visible = true;
          Message.Visible = false;  
      }
  }
 
private void LoadConn(int score)
{
    int percent;
    percent = (score*100)/7;  
  
    // Create the objects 
    OleDbConnection conn;
    OleDbCommand comm;
    
    // Instance the connection open it
    conn = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source ="+ Server.MapPath("assessments.accdb")+";User Id=; Jet OLEDB:Database Password=;");
    conn.Open();
    
    // Create the insert SQL 
    string sSQL = "";
		string qname = "plagiarism"; 
    sSQL = "Insert into posttest_table(fname,lname,username,coursenum,emailId,emailId2,status,school,qname,answered,score,q1,q2,q3,q4,q5,q6,q7) values('" + fname.Text + "','" + lname.Text +"','" + portal_id.Text +"','"+course_id.Text+"','"+emailId.Text+"','"+emailId2.Text+"','"+(status.SelectedIndex+1)+"','"+ school.Text +"','"+(qname)+"',"+score+","+percent+","+(q1.SelectedIndex+1)+","+(q2.SelectedIndex+1)+","+(q3.SelectedIndex+1)+","+(q4.SelectedIndex+1)+","+(q5.SelectedIndex+1)+","+(q6.SelectedIndex+1)+","+(q7.SelectedIndex+1)+");";
   
    //  Response.Write(sSQL + "<br />");
    //  Response.End();
    //  return;
    
    // Create a command object from the connection
    comm = conn.CreateCommand ();
    comm.CommandText = sSQL;
    comm.CommandType = CommandType.Text;
 
    // Try the insert 
    try
    {
        comm.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Response.Write("Error During DB Update: " + ex.ToString());
    }
    
    
   
    conn.Close();
    // Inserting data into the database end
     
    // Create the email body text
/* String bodyInfo = fname.Text+" "+lname.Text+" has taken the exam.\n <br />"+fname.Text  +" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option 3)<br /> You Answered:  Option "+(q1.SelectedIndex+1)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option 5) <br />You Answered: Option "+(q2.SelectedIndex+1)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option 3) <br />You Answered: Option "+(q3.SelectedIndex+1)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option 1) <br />You Answered: Option "+(q4.SelectedIndex+1)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option 6) <br />You Answered: Option "+(q5.SelectedIndex+1)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option 2) <br />You Answered: Option "+(q6.SelectedIndex+1)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option 3) <br /> You Answered: Option "+(q7.SelectedIndex+1);*/
 
 String bodyInfo = fname.Text+" "+lname.Text+" is a/an "+status.Text+", and has taken the exam for the course "+course_id.Text+".\n <br />"+fname.Text+" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option c)<br /> You Answered:  Option "+Convert.ToChar(q1.SelectedIndex+97)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option e) <br />You Answered: Option "+Convert.ToChar(q2.SelectedIndex+97)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option c) <br />You Answered: Option "+Convert.ToChar(q3.SelectedIndex+97)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option a) <br />You Answered: Option "+Convert.ToChar(q4.SelectedIndex+97)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option f) <br />You Answered: Option "+Convert.ToChar(q5.SelectedIndex+97)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option b) <br />You Answered: Option "+Convert.ToChar(q6.SelectedIndex+97)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option c) <br /> You Answered: Option "+Convert.ToChar(q7.SelectedIndex+97);
 
 
    // Create SMTP client
    SmtpClient client = new SmtpClient("mail.twu.edu");
        
    // Create SMTP message
    MailMessage message = new MailMessage();
 
    // Set message properties 
    message.From = new MailAddress ("");
    message.To.Add("");
    message.CC.Add(emailId.Text);
   if (!string.IsNullOrEmpty(emailId2.Text))
    {
       message.CC.Add(emailId2.Text);
    }
    message.Body = bodyInfo;
    message.Subject = "Doing Research: Plagiarism Quiz Results";
    message.IsBodyHtml = true;
   
    try
        {
 
            // Send EMail
            client.Send(message);
        }
        catch (Exception ex)
        {
            // Do Nothing  
        }
				
 
    // Send the user to the Results page
    Response.Redirect("results.aspx?fname="+fname.Text+"&lname="+lname.Text+"&score="+percent+"&q1="+(q1.SelectedIndex)+"&q2="+(q2.SelectedIndex)+"&q3="+(q3.SelectedIndex)+"&q4="+(q4.SelectedIndex)+"&q5="+(q5.SelectedIndex)+"&q6="+(q6.SelectedIndex)+"&q7="+(q7.SelectedIndex));
 
}
 
 
void status_SelectedIndexChanged(object sender, System.EventArgs e)
{
   
   if (statusAns.SelectedValue == "status_guest") {
        RequiredFieldValidator4.enabled = true;
   }
    else {
         RequiredFieldValidator4.enabled = false;
   }
    
 }
 
 
 
 
 </script>

Open in new window

0
Anurag ThakurTechnical ManagerCommented:
i coudnt find statusAns control and i have assumed it to be a drop down as you were using .SelectedValue for that
i am using the following code and its compiling
i dont what all is being discussed because it does not matter if the code is inline or in a separate class
please go through my attached code and see if it works for you
	protected void status_SelectedIndexChanged (object sender, System.EventArgs e)
	{
 
		if (statusAns.SelectedValue == "status_guest")
		{
			RequiredFieldValidator4.Enabled = true;
		}
		else
		{
			RequiredFieldValidator4.Enabled = false;
		}
	}
 
		<asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">
			<asp:ListItem Value="undergraduate">
			</asp:ListItem>
			<asp:ListItem Value="graduate">
			</asp:ListItem>
			<asp:ListItem Value="fs">
			</asp:ListItem>
			<asp:ListItem Value="guest">
			</asp:ListItem>
		</asp:RadioButtonList>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="status" ErrorMessage="Status" Text="*Status Required"></asp:RequiredFieldValidator><br />
		If you are a guest user,
		<br />
		please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="school" ErrorMessage="School Name" Text="*School Name Required"></asp:RequiredFieldValidator>
		<asp:DropDownList ID="statusAns" runat="server">
		</asp:DropDownList>

Open in new window

0
jianxin9Author Commented:
ragi0017, thanks so much!  this is definitely getting me closer.  Actually there is no drop down.  Basically what I need is that if they select "guest" from the Radio Button List, the text box needs to be required.  
I am now trying the following but I am getting another runtime error.  

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>



protected void status_SelectedIndexChanged (object sender, System.EventArgs e)
	{
 
		if (status_SelectedIndexChanged  == "guest")
		{
			RequiredFieldValidator4.Enabled = true;
		}
		else
		{
			RequiredFieldValidator4.Enabled = false;
		}
	}
<asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">
			<asp:ListItem Value="undergraduate">
			</asp:ListItem>
			<asp:ListItem Value="graduate">
			</asp:ListItem>
			<asp:ListItem Value="fs">
			</asp:ListItem>
			<asp:ListItem Value="guest">
			</asp:ListItem>
		</asp:RadioButtonList>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="status" ErrorMessage="Status" Text="*Status Required"></asp:RequiredFieldValidator><br />
		If you are a guest user,
		<br />
		please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="school" ErrorMessage="School Name" Text="*School Name Required"></asp:RequiredFieldValidator>
 
  

Open in new window

0
Anurag ThakurTechnical ManagerCommented:
modify your line no. 4
you cannot use the function name to copmpare text as you have done htere if (status_SelectedIndexChanged  == "guest")
modify it to if (status.SelectedItem.Text == "guest")
0
jianxin9Author Commented:
Thanks very much.  Okay--now the quiz is showing up (runtime error is gone), but when I click on one of the radio buttons in this list is is taking me to a page that has the same runtime error I was getting earlier.  

<asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">
                  <asp:ListItem Value="undergraduate">
                  </asp:ListItem>
                  <asp:ListItem Value="graduate">
                  </asp:ListItem>
                  <asp:ListItem Value="fs">
                  </asp:ListItem>
                  <asp:ListItem Value="guest">
                  </asp:ListItem>
            </asp:RadioButtonList>


0
Anurag ThakurTechnical ManagerCommented:
i dont really understand what you mean to say - but when I click on one of the radio buttons in this list is is taking me to a page that has the same runtime error I was getting earlier.  

i cannot see anywhere in your posted code that the user is being rediected to any page?
can you please provide more details
0
CtrlAltDlCommented:
Change this code:
protected void status_SelectedIndexChanged

to this:
void status_SelectedIndexChanged
0
jianxin9Author Commented:
Thanks--when I try that it's the same thing.  If I click on one of the radio buttons, I get an error message on page (sorry it doesn't go to a new page):

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

0
Anurag ThakurTechnical ManagerCommented:
this message you have already shared
can you please share your code becasue i cannot see any place in your already shared code from where i can be redirected to the next page so that i can get the exception
is your applicaion compiling in the visual studio IDE?
0
jianxin9Author Commented:
Thanks--here is the full code below.  It is compiling.
<%@ Page Language="c#" Debug="true"%>
 
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Net" %>
 
<script runat="server" language="C#">
		 
 
 
  void Page_Load()
  {
      if (Page.IsPostBack)
      {
          questionsPanel.Visible = false;
          Message.Visible = true;  
          int correct = 0;
          if (q1.SelectedIndex == 2) correct++;
          if (q2.SelectedIndex == 4) correct++;
          if (q3.SelectedIndex == 2) correct++;
          if (q4.SelectedIndex == 0) correct++;
          if (q5.SelectedIndex == 5) correct++;
          if (q6.SelectedIndex == 1) correct++;
          if (q7.SelectedIndex == 2) correct++;
 
          LoadConn(correct);
      }
      else
      {
          questionsPanel.Visible = true;
          Message.Visible = false;  
      }
  }
 
private void LoadConn(int score)
{
    int percent;
    percent = (score*100)/7;  
  
    // Create the objects 
    OleDbConnection conn;
    OleDbCommand comm;
    
    // Instance the connection open it
    conn = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source ="+ Server.MapPath("assessments.accdb")+";User Id=Admin; Jet OLEDB:Database Password=Live4Ever;");
    conn.Open();
    
    // Create the insert SQL 
    string sSQL = "";
		string qname = "plagiarism"; 
    sSQL = "Insert into posttest_table(fname,lname,username,coursenum,emailId,emailId2,status,school,qname,answered,score,q1,q2,q3,q4,q5,q6,q7) values('" + fname.Text + "','" + lname.Text +"','" + portal_id.Text +"','"+course_id.Text+"','"+emailId.Text+"','"+emailId2.Text+"','"+(status.SelectedIndex+1)+"','"+ school.Text +"','"+(qname)+"',"+score+","+percent+","+(q1.SelectedIndex+1)+","+(q2.SelectedIndex+1)+","+(q3.SelectedIndex+1)+","+(q4.SelectedIndex+1)+","+(q5.SelectedIndex+1)+","+(q6.SelectedIndex+1)+","+(q7.SelectedIndex+1)+");";
   
    //  Response.Write(sSQL + "<br />");
    //  Response.End();
    //  return;
    
    // Create a command object from the connection
    comm = conn.CreateCommand ();
    comm.CommandText = sSQL;
    comm.CommandType = CommandType.Text;
 
    // Try the insert 
    try
    {
        comm.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Response.Write("Error During DB Update: " + ex.ToString());
    }
    
    
   
    conn.Close();
    // Inserting data into the database end
     
    // Create the email body text
/* String bodyInfo = fname.Text+" "+lname.Text+" has taken the exam.\n <br />"+fname.Text  +" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option 3)<br /> You Answered:  Option "+(q1.SelectedIndex+1)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option 5) <br />You Answered: Option "+(q2.SelectedIndex+1)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option 3) <br />You Answered: Option "+(q3.SelectedIndex+1)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option 1) <br />You Answered: Option "+(q4.SelectedIndex+1)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option 6) <br />You Answered: Option "+(q5.SelectedIndex+1)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option 2) <br />You Answered: Option "+(q6.SelectedIndex+1)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option 3) <br /> You Answered: Option "+(q7.SelectedIndex+1);*/
 
 String bodyInfo = fname.Text+" "+lname.Text+" is a/an "+status.Text+", and has taken the exam for the course "+course_id.Text+".\n <br />"+fname.Text+" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option c)<br /> You Answered:  Option "+Convert.ToChar(q1.SelectedIndex+97)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option e) <br />You Answered: Option "+Convert.ToChar(q2.SelectedIndex+97)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option c) <br />You Answered: Option "+Convert.ToChar(q3.SelectedIndex+97)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option a) <br />You Answered: Option "+Convert.ToChar(q4.SelectedIndex+97)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option f) <br />You Answered: Option "+Convert.ToChar(q5.SelectedIndex+97)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option b) <br />You Answered: Option "+Convert.ToChar(q6.SelectedIndex+97)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option c) <br /> You Answered: Option "+Convert.ToChar(q7.SelectedIndex+97);
 
 
    // Create SMTP client
    SmtpClient client = new SmtpClient("mail.twu.edu");
        
    // Create SMTP message
    MailMessage message = new MailMessage();
 
    // Set message properties 
    message.From = new MailAddress ("automailer@twu.edu");
    message.To.Add("tutorial-results@mail.twu.edu");
    message.CC.Add(emailId.Text);
   if (!string.IsNullOrEmpty(emailId2.Text))
    {
       message.CC.Add(emailId2.Text);
    }
    message.Body = bodyInfo;
    message.Subject = "Doing Research: Plagiarism Quiz Results";
    message.IsBodyHtml = true;
   
    try
        {
 
            // Send EMail
            client.Send(message);
        }
        catch (Exception ex)
        {
            // Do Nothing  
        }
				
 
    // Send the user to the Results page
    Response.Redirect("results.aspx?fname="+fname.Text+"&lname="+lname.Text+"&score="+percent+"&q1="+(q1.SelectedIndex)+"&q2="+(q2.SelectedIndex)+"&q3="+(q3.SelectedIndex)+"&q4="+(q4.SelectedIndex)+"&q5="+(q5.SelectedIndex)+"&q6="+(q6.SelectedIndex)+"&q7="+(q7.SelectedIndex));
 
}
 
 
void status_SelectedIndexChanged (object sender, System.EventArgs e)
	{
 
		if (status.SelectedItem.Text == "guest")
		{
			RequiredFieldValidator4.Enabled = true;
		}
		else
		{
			RequiredFieldValidator4.Enabled = false;
		}
	}
 
 
 
 
 
 </script>
 
   
 
 
<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Doing Research: Plagiarism Quiz</title>
    <meta name="Description" content="Texas Woman's University, with campuses in Denton, Dallas, and Houston, offers bachelor's, master's, and doctoral degrees to its students in the health sciences, the liberal arts, the fine arts, the sciences, and business." />
    <meta name="Keywords" content="texas woman's university, TWU, web guidelines, webspinners" />
    <link href="http://www.twu.edu/library/css/screen.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="http://www.twu.edu/library/css/print.css" rel="stylesheet" type="text/css" media="print" />
    <link href="http://www.twu.edu/library/css/all2_tab.css" rel="stylesheet" type="text/css" media="screen" />
    <script type="text/javascript" src="http://www.twu.edu/library/js/TAB_Function_Lib.js"></script>
 
 
 
 
 
 
 
    <style type="text/css">
        #Layer1 {
	        position:absolute;
	        width:186px;
	        height:18px;
	        z-index:3;
	        left: 407px;
	        top: 85px;
        }
        #Layer2 {
	        position:absolute;
	        width:421px;
	        height:30px;
	        z-index:4;
	        left: 603px;
	        top:78px;
        }
        .style1 {
	        font-size: 10px;
x	        color: #FFFFFF;
        }
        .style2 {font-size: 10px}
    </style>
</head>
 
 <body onUnload="TAB_GLOBAL_UNINITIALIZE(Array(Example));">
 
    </div>
<!-- InstanceBeginEditable name="content" -->
     <h2>Doing Research: Plagiarism Final</h2>
 <div class="heading">Please Enter Your Information</div>
<Fieldset>
<legend>Please provide the following. Items marked with * are required.</legend>
<form id="Form1" name="ctl00" method="post" action="default.aspx" runat="server">
                    <asp:label id="Message" runat="server" />
 
                        <asp:Panel id = "questionsPanel" runat ="server">
                        <asp:Label ID="Errors" runat="server" />
                        First Name:*<br />
                        <asp:TextBox ID="fname" runat="Server" /><br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="fname"
                            ErrorMessage="First Name" runat="server" Text="*First Name Required"></asp:RequiredFieldValidator>
                        <br />
                        Last Name:*<br />
                        <asp:TextBox ID="lname" runat="Server" /><br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="lname"
                            ErrorMessage="Last Name" runat="server" Text="*Last Name Required"></asp:RequiredFieldValidator>
                        <br />
						Status:*<br />														
  <asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">
			<asp:ListItem Value="undergraduate">
			</asp:ListItem>
			<asp:ListItem Value="graduate">
			</asp:ListItem>
			<asp:ListItem Value="fs">
			</asp:ListItem>
			<asp:ListItem Value="guest">
			</asp:ListItem>
		</asp:RadioButtonList>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="status" ErrorMessage="Status" Text="*Status Required"></asp:RequiredFieldValidator><br />
		If you are a guest user,
		<br />
		please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="school" ErrorMessage="School Name" Text="*School Name Required"></asp:RequiredFieldValidator>
 
  <br /><br />
 
 
                        Portal Username: (optional)<br />
                        <asp:TextBox ID="portal_id" runat="Server" />
                        <br />
                        <br />
												Course Name, Number and Section: (optional-ex. ENG-1023.15)<br />
                        <asp:TextBox ID="course_id" runat="Server" />
                        <br />
                        <br />
                        Your Email Address:* (a copy of your results will be sent to this address)<br />
                        <asp:TextBox ID="emailId" runat="Server" />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ControlToValidate="emailId"
                            ErrorMessage="Email" runat="Server" Text="*Email Address Is Required"></asp:RequiredFieldValidator><br />
                        <br />
                        Your Professor's Email Address: (optional-send your results to your professor)<br />
                        <asp:TextBox ID="emailId2" runat="Server" />
                        <br />
                        <p>
              
             
										  Please choose the best answer.</p>
                        <p>
                            1. Plagiarism is the act of:
                            <br />
                            <asp:RadioButtonList ID="q1" runat="server">
                                <asp:ListItem id="q1a" runat="server" Value="a. using someone else's work and citing it" />
                                <asp:ListItem id="q1b" runat="server" Value="b. using copyrighted materials for your paper" />
                                <asp:ListItem id="q1c" runat="server" Value="c. using someone else's work and not giving them credit" />
                                <asp:ListItem id="q1d" runat="server" Value="d. paraphrasing" />
                            </asp:RadioButtonList>
                        </p>
                        <p>
                            2. Which of the following is copyrighted infringement?
                            <br />
                            <asp:RadioButtonList ID="q2" runat="server">
                                <asp:ListItem id="q2a" runat="server" Value="a. photocopying a college textbook" />
                                <asp:ListItem id="q2b" runat="server" Value="b. burning a CD that you did not own" />
                                <asp:ListItem id="q2c" runat="server" Value="c. downloading music or movies that you did not pay for" />
                                <asp:ListItem id="q2d" runat="server" Value="d. buying and submitting papers that you did not write" />
                                <asp:ListItem id="q2e" runat="server" Value="e. all of the above" />
                            </asp:RadioButtonList>
                        </p>
                        <p>
                            3. Accidental plagiarism is:
                            <br />
                            <asp:RadioButtonList ID="q3" runat="server">
                                <asp:ListItem id="q3a" runat="server" Value="a. acceptable one time, as long as it was only an accident" />
                                <asp:ListItem id="q3b" runat="server" Value="b. okay if you paraphrased or changed the text a bit" />
                                <asp:ListItem id="q3c" runat="server" Value="c. always unacceptable" />
                            </asp:RadioButtonList>
                        </p>
                        <p>
                            4. When citing my resources it is important that I:
                            <br />
                            <asp:RadioButtonList ID="q4" runat="server">
                                <asp:ListItem id="q4a" runat="server" Value="a. use a standard citation format assigned by your professor" />
                                <asp:ListItem id="q4b" runat="server" Value="b. include only the title and year" />
                                <asp:ListItem id="q4c" runat="server" Value="c. use footnotes, in-text citations, and italics for every citation" />
                                <asp:ListItem id="q4d" runat="server" Value="d. all of the above" />
                            </asp:RadioButtonList>
                        </p>
                        <p>
                            5. RefWorks can help you:
                            <br />
                            <asp:RadioButtonList ID="q5" runat="server">
                                <asp:ListItem id="q5a" runat="server" Value="a. organize your research" />
                                <asp:ListItem id="q5b" runat="server" Value="b. only when you are using the MLA citation style" />
                                <asp:ListItem id="q5c" runat="server" Value="c. import references from many different data sources" />
                                <asp:ListItem id="q5d" runat="server" Value="d. create bibliographies using several citation styles" />
                                <asp:ListItem id="q5e" runat="server" Value="e. all of the above" />
                                <asp:ListItem id="q5f" runat="server" Value="f. a, c, d" />
                            </asp:RadioButtonList>
                        </p>
                        <p>
                            6. Which of the following best describes plagiarism?
                            <br />
                            <asp:RadioButtonList ID="q6" runat="server">
                                <asp:ListItem id="q6a" runat="server" Value="a. A temporary fix until you have time to re-do the work" />
                                <asp:ListItem id="q6b" runat="server" Value="b. It's a serious offense and can result in severe penalties" />
                                <asp:ListItem id="q6c" runat="server" Value="c. It's easy to commit and not easy to detect" />
                                <asp:ListItem id="q6d" runat="server" Value="d. a and b" />
                            </asp:RadioButtonList>
                        </p>
                        <p>
                            7. When do you have to cite your resources?
                            <br />
                            <asp:RadioButtonList ID="q7" runat="server">
                                <asp:ListItem id="q7a" runat="server" Value="a. when what you are writing about is your own experience" />
                                <asp:ListItem id="q7b" runat="server" Value="b. when what you are writing about is common knowledge" />
                                <asp:ListItem id="q7c" runat="server" Value="c. when what you are writing about is someone else's idea" />
                            </asp:RadioButtonList>
                        </p>
                     
												
  <asp:Button ID="b1" Text="Submit" runat="server" />
                        <asp:ValidationSummary ID="ValidationSummary1" ShowMessageBox="true" ShowSummary="false"
                            HeaderText="You must enter a value in the following fields:" EnableClientScript="true"
                            runat="server" />
                     </asp:Panel>
                   </form>
 <!-- InstanceEndEditable --></td>
  </tr>
  <tr>
    <td id="footer"></td>
  </tr>
</table>
 
 
</body>
<!-- InstanceEnd -->
</html>

Open in new window

0
CtrlAltDlCommented:
Change your web.config file.  Turn the customerErrors off (see below).

    <customErrors mode="Off"/>

Also make sure it is the same in your machine.Config file on your development computer.  That can be found here:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
0
jianxin9Author Commented:
Thanks CtrlAltDl.  I've actually done that already and am still having this problem.
0
CtrlAltDlCommented:
Yea, but you should be able to see the actual details of the error if customer errors is off.

After you've done that tell us what the details of that error is.
0
jianxin9Author Commented:
Hmm....yeah, I see what you mean.  I can't see anything other than that error though.  i don't know--this problem may be unsolvable--I've been posting questions on it for about the last week and a half.  
0
CtrlAltDlCommented:
That makes it HARD to troubleshoot.  Is your application hosted?  Is it on your machine or a development server?  Is you app a virtual directory?


BTW, you still have an access modifier for LoadConn.

Change this:
private void LoadConn(int score)

to this:
void LoadConn(int score)

0
jianxin9Author Commented:
I know it makes it very hard.  I appreciate you trying to help.  I am working off a dev server.

Okay, this is the piece of code that is causing the runtime error to show up when I click on a radio button:
AutoPostBack="true" from the code below.  When I take this out, it eliminates that problem but  when I selectn a radio button selected that isn't the one that I want to require the textbox, the validator is still popping up for it.  

Again, this might not even be possible, but I wanted to try.
			Status:*<br />														
  <asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">
			<asp:ListItem Value="undergraduate">
			</asp:ListItem>
			<asp:ListItem Value="graduate">
			</asp:ListItem>
			<asp:ListItem Value="fs">
			</asp:ListItem>
			<asp:ListItem Value="guest">
			</asp:ListItem>
		</asp:RadioButtonList>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="status" ErrorMessage="Status" Text="*Status Required"></asp:RequiredFieldValidator><br />
		If you are a guest user,
		<br />
		please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="school" ErrorMessage="School Name" Text="*School Name Required"></asp:RequiredFieldValidator>
 
  <br /><br />

Open in new window

0
jianxin9Author Commented:
Okay, wait--here is the error I get when i click on a radio button:

 The parameter 'addresses' cannot be an empty string.
Parameter name: addresses
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The parameter 'addresses' cannot be an empty string.
Parameter name: addresses

Source Error:

Line 91:     message.From = new MailAddress ("automailer@twu.edu");
Line 92:     message.To.Add("tutorial-results@mail.twu.edu");
Line 93:     message.CC.Add(emailId.Text);
Line 94:    if (!string.IsNullOrEmpty(emailId2.Text))
Line 95:     {
0
jianxin9Author Commented:
If I go ahead and fill out the required email box before selecting a radio button, then selecting a radio button submits the quiz.
0
CtrlAltDlCommented:
You need to check if there is a email address, like you do for the second CC address.

   if (!string.IsNullOrEmpty(emailId.Text))
    {
       message.CC.Add(emailId.Text);
    }
   if (!string.IsNullOrEmpty(emailId2.Text))
    {
       message.CC.Add(emailId2.Text);
    }
0
CtrlAltDlCommented:
BTW, if you view this app on your dev server's browser do you see detailed errors?
0
jianxin9Author Commented:
I can see a source error and that's about it.  When I add that code I am still getting an error when I click on a radio button:

 The parameter 'addresses' cannot be an empty string.
Parameter name: addresses
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The parameter 'addresses' cannot be an empty string.
Parameter name: addresses

Source Error:

Line 91:     message.From = new MailAddress ("automailer@twu.edu");
Line 92:     message.To.Add("tutorial-results@mail.twu.edu");
Line 93:     message.CC.Add(emailId.Text);
Line 94:   if (!string.IsNullOrEmpty(emailId.Text))
Line 95:     {
0
CtrlAltDlCommented:
See my post above from 11:09AM
0
jianxin9Author Commented:
Thanks!  That's the code I added and am still getting that error.  This is what I put in:

  message.CC.Add(emailId.Text);
  if (!string.IsNullOrEmpty(emailId.Text))
    {
       message.CC.Add(emailId.Text);
    }
   if (!string.IsNullOrEmpty(emailId2.Text))
    {
       message.CC.Add(emailId2.Text);
    }
0
CtrlAltDlCommented:
Nope, you need to remove this:
message.CC.Add(emailId.Text);

Your adding the CC twice, but you only need to have add emalld.Text if it is not null.
0
jianxin9Author Commented:
Very cool, thank you!  Now when I click on any radio button, I am basically submitting the quiz and being taken to the results page.  it seems that there is something weird with AutoPostBack="true" from the code below:

 <asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">
Status:*<br />														
  <asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">
			<asp:ListItem Value="undergraduate">
			</asp:ListItem>
			<asp:ListItem Value="graduate">
			</asp:ListItem>
			<asp:ListItem Value="fs">
			</asp:ListItem>
			<asp:ListItem Value="guest">
			</asp:ListItem>
		</asp:RadioButtonList>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="status" ErrorMessage="Status" Text="*Status Required"></asp:RequiredFieldValidator><br />
		If you are a guest user,
		<br />
		please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="school" ErrorMessage="School Name" Text="*School Name Required"></asp:RequiredFieldValidator>
 
  <br /><br />

Open in new window

0
jianxin9Author Commented:
Actually, I am going to close this out and start up another one.  Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.