I am trying to get an integer value from my controller to my view, and then adding that value as a Hidden Field to be used later in my JavaScript client-code.
I am getting an exception while trying to add the hidden field.
Here is the steps to reproduce:
My cshtml page:
@model Int32
@{
ViewBag.Title = "GetGeneric";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section DetailJavascript
{
@Scripts.Render("~/Scripts/Generic.js")
}
@Html.HiddenFor(model => model, new { id = "GenericID" });
<h2>GetGeneric</h2>
And here is my Controller code:
public ActionResult GetCategoryDetail(int id)
{
Object p = id;
return View(p); //I added a breakpoint here and the value of variable 'p' is not null !!
}
EDIT: Exception Details
Thank you!