Developing Exam Software in MVC 5. I am Completely new to MVC. I want to Compare selected Answers by student with Correct Options available in database. but When i click on Submit button it show null reference Exception. i think the selected answer are not passed to controller. Please Help me Out. Thanx in Advance. (Radio button value are taken from database.)

MayankPosted Jan 19, 2017, 8:58 AM
{
public string Question { get; set; }
public string Answer { get; set; }
public string Option1{ get; set; }
public string Option2 { get; set; }
public string Option3 { get; set; }
public string Option4 { get; set; }
}
public ActionResult GetQuestions()
{
List
var user = new Questions
{
Question="Question1",
Option1 = "A",
Option2 = "B",
Option3 = "C",
Option4 = "D",
};
var user2 = new Questions
{
Question = "Question2",
Option1 = "A",
Option2 = "B",
Option3 = "C",
Option4 = "D",
};
var user3 = new Questions
{
Question = "Question3",
Option1 = "A",
Option2 = "B",
Option3 = "C",
Option4 = "D",
};
students.Add(user);
students.Add(user2);
students.Add(user3);
return View(students);
}
[HttpPost]
public ActionResult GetQuestions(List
{
return View();
}
@model IEnumerable
@{
ViewBag.Title = "GetQuestions";
}
GetQuestions
@using (Html.BeginForm("GetQuestions", "Home", FormMethod.Post))
{
if (Model != null)
{
for (int i = 0; i < @Model.Count(); i++)
{
}
}
}
If it resolve your query please mark as answer.
ravi vermaPosted Jan 18, 2017, 1:13 PM