I'm new to MVC 3 and I have the following views:
Index:
@using (Html.BeginForm())
{
@Html.Hidden("id", "1")
<input type="submit" value="Submit" />
}
Main:
@using (Html.BeginForm())
{
@Html.Hidden("id", "2")
<input type="submit" value="Save" />
}
And the following Controller:
public ActionResult Index()
{
ViewBag.Message = "Welcome!";
return View();
}
[HttpPost]
public ActionResult Index(string id)
{
if ("1".Equals(id))
{
return View("Main");
}
else("2".Equals(id))
{
return View();
}
}
My expectation would be that the Main view would render the hidden input with a value of "2". However, upon reaching the Main page, and inspecting the source, the value is still being set to "1". Any idea what I'm doing wrong here?