i have given some user information in controller in the form of json(java script object notation) object here
now i need to get this data to view page from controller using "VewBag"(it is for displaying user information ex :"Details.cshtmal") .So wt code i have to write here to get data from controller to view?
This is my code in controller page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace YummyBakesASPNETMVC.Controllers
{
public class JKController : Controller
{
//
// GET: /JK/
public ActionResult Index()
{
MyRecipe myjsonobj = new MyRecipe();
myjsonobj.Id = 1;
myjsonobj.FirstName = "Serina";
myjsonobj.MiddleName = "Seri";
myjsonobj.Description = "My Info";
myjsonobj.LastName = "Seru";
myjsonobj.Sex = "FeMale";
myjsonobj.DateOfBirth = "09/09/1988";
myjsonobj.MaritialStatus = "Single";
myjsonobj.Occupation = "Employee";
myjsonobj.OrganDonar = "LKJ";
myjsonobj.HomeTelNo = 040987654;
myjsonobj.MobileNo = 9187518223;
myjsonobj.Religion = "Hindu";
myjsonobj.Address = "KKpet";
myjsonobj.Street = "RR";
myjsonobj.Town = "YY";
myjsonobj.ZipCode = 909786;
myjsonobj.Ethencity = "TRE";
ViewBag.JsonData = Json(myjsonobj);
return View();
}
public ActionResult Details(int id)
{
MyRecipe myjsonobj = new MyRecipe();
myjsonobj.Id = 1;
myjsonobj.FirstName = "Serina";
myjsonobj.MiddleName = "Seri";
myjsonobj.Description = "My Info";
myjsonobj.LastName = "Seru";
myjsonobj.Sex = "FeMale";
myjsonobj.DateOfBirth = "09/09/1988";
myjsonobj.MaritialStatus = "Single";
myjsonobj.Occupation = "Employee";
myjsonobj.OrganDonar = "LKJ";
myjsonobj.HomeTelNo = 040987654;
myjsonobj.MobileNo = 9187518223;
myjsonobj.Religion = "Hindu";
myjsonobj.Address = "KKpet";
myjsonobj.Street = "RR";
myjsonobj.Town = "YY";
myjsonobj.ZipCode = 909786;
myjsonobj.Ethencity = "TRE";
ViewBag.JsonData = Json(myjsonobj);
// = new {
// lastTradePrice = 50,
// lastUpdated = "10/1/2010",
// expirationDate = "10/2/2010",
// success = true
//},
//JsonRequestBehavior = JsonRequestBehavior.AllowGet
//ViewBag.PageId = "recipe-details";
//return View(SampleRecipes.Recipes.Single(r => r.Id == id));
return View();
}
}
}
Now i need to get this details from above page(controller page) and i have to display in viewpage(.cshtml) using "ViewBag" object in viewpage ?