Essentially, what I am trying to do is allow a user to take a quiz, that consists of five questions. When the user is done with the quiz they will click the button at the bottom at that form. I am trying to get the result from a selected Radio Button in a Radio Button List, which I believe I have set up, to a Result Web Form that will say if they got each question right or wrong. The problem I am running into now is that there are two Web Forms that a user can take a quiz on, and I can't seem to change the 'Result' Web Form's text boxes to public. Then I could manipulate the text box in the corresponding button method. So, I added a button in the 'Result' a button that when clicked will take a specific quiz. I have yet to find a way to set up an IF STATEMENT, so I don't have to specify a quiz. I'll put my code below.
Quiz Chapter 10 Ex.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Home2
{
public partial class Chapter10 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string result;
public string quiz = "Chapter 10 - Classes and Objects: A Deeper Look";
protected void chapter10SubmitButton_Click(object sender, EventArgs e)
{
if (ch10RadioButtonList1.SelectedValue == "false")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
if (ch10RadioButtonList2.SelectedValue == "false")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
if (ch10RadioButtonList3.SelectedValue == "false")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
if (ch10RadioButtonList4.SelectedValue == "false")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
if (ch10RadioButtonList5.SelectedValue == "false")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
}
}
}
Quiz Chapter 8 Ex.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Home2
{
public partial class Chapter8 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string result;
public string quiz = "Chapter 8 - Arrays; Introduction to Exception Handling";
protected void chapter10SubmitButton_Click(object sender, EventArgs e)
{
if (ch8RadioButtonList1.SelectedValue == "true")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
if (ch8RadioButtonList2.SelectedValue == "false")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
if (ch8RadioButtonList3.SelectedValue == "true")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
if (ch8RadioButtonList4.SelectedValue == "true")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
if (ch8RadioButtonList5.SelectedValue == "false")
{
//Result Textbox 1 .text = "Correct"
result = "Correct";
}
else
{
//Result Textbox1 .text = "Incorrect"
result = "Incorrect";
}
}
protected void chapter8SubmitButton_Click(object sender, EventArgs `e)`
{
Response.Redirect("Result.aspx");
}
}
}
Result Ex.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Home2
{
public partial class Result : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
StudentEntities dbcon = new StudentEntities();
public Chapter10 Chapter10Form;
public Chapter8 Chapter8Form;
public int count = 0;
protected void seeResultsButton_Click(object sender, EventArgs e)
{
quizTextBox.Text = Chapter10Form.quiz;
question1TextBox.Text = Chapter10Form.result;
question2TextBox.Text = Chapter10Form.result;
question3TextBox.Text = Chapter10Form.result;
question4TextBox.Text = Chapter10Form.result;
question5TextBox.Text = Chapter10Form.result;
if(question1TextBox.Text == "Correct")
{
count++;
}
if(question2TextBox.Text == "Correct")
{
count++;
}
if(question3TextBox.Text == "Correct")
{
count++;
}
if(question4TextBox.Text == "Correct")
{
count++;
}
if(question5TextBox.Text == "Correct")
{
count++;
}
totalTextBox.Text = count.ToString();
}
}
}