In my MVC controller, I created an 'object' which I'm simplifying as 'student'. I'm using ViewBag to pass it on to my view.
In my controller, I have:
ViewBag.Student = new {
Id = "52",
Value = JsonConvert.SerializeObject(new
{
StudentName = oneStudent.Name,
Age = oneStudent.Age,
FavoriteColor = oneStudent.Color,
Height = oneStudent.Height
}),
Text = oneStudent.Name + " --- " + oneStudent.Age,
};
I started off my calling the ViewBag, using
@{
var student = ViewBag.Student;
}
and I want to use span (or anything similar) to display the data. My attempt was using some code along the lines of "@Student.Value" in the html code, but that didn't work.
Any help would be greatly appreciated. Thank you.