I'm a Beginner. I'm making a Multiple Choice Quiz. I want the results from ALL my Buttons to display in my Label when the user Submits their answers. How do I do this?
- (2 Questions) 4 Radio Buttons
- 1 DropDown (ID="DropDownList1")
- 1 CheckBox (ID="CheckBoxList1")
1 FeedBack/ShortAnswer TextBox
Submit Button
- Results Label
Basically I want it to display like this:
Results:
You answered 2 questions correctly
- Question 1 is Correct
- Question 2 is Incorrect. The correct answer is True.
- Question 3 is Correct
I like apples because they are good for your health.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Text;
using System.Web.UI.WebControls;
namespace Project4
{
public partial class Project4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void ClickHereForMore_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("https://my.sunysuffolk.edu/web/home-community/activities-information");
}
protected void SubmitButton_Click(object sender, ImageClickEventArgs e)
{
if (RadioButtonTrue.Checked)
{
lblResults.Text = "Question 1 is Correct";
}
else if (RadioButtonFalse.Checked)
{
lblResults.Text = "Question 1 is False. Correct answer is True.";
}
if (RadioButtonYes.Checked)
{
lblResults.Text = "Question 2 is Correct";
}
else if (RadioButtonNo.Checked)
{
lblResults.Text = "Question 2 is False. Correct answer is True.";
}
}
protected void FeedBack_TextChanged(object sender, EventArgs e)
{
lblResults.Text = FeedBack.Text;
}
}
}
One of my problems right now is that the RadioButton is displaying only the Results of Question 2. I think I know why, but I don't know how to fix it so that it will display both Question 1 and 2 answers. I can only imagine this issue becoming bigger when I try to do the same for the other buttons. Also the feedback text isn't displaying.