I am new to MVC and is using MVc4 with VS2013. This is my controller:
[HttpPost]
public ActionResult Create(CreateRequestViewModel viewModel)
{
if (ModelState.IsValid)
{
return RedirectToAction("Index");
}
return View(viewModel);
}
Below is my view:
@model ProMs.Web.ViewModels.CreateRequestViewModel
@{
ViewBag.Title = "Create";
}
<body>
<h2>New Request</h2>
<h3></h3>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<div class="float-left">
<label for="RequestName">Request</label>
@Html.EditorFor(model => model.Request.RequestName)
@Html.ValidationMessageFor(model => model.Request.RequestName)
@Html.LabelFor(model => model.Request.Requestor)
@Html.EditorFor(model => model.Request.Requestor)
@Html.ValidationMessageFor(model => model.Request.Requestor)
@Html.LabelFor(model => model.Request.Purpose)
@Html.EditorFor(model => model.Request.Purpose)
@Html.ValidationMessageFor(model => model.Request.Purpose)
</div>
<div class="float-right">
@Html.LabelFor(model => model.Request.Investigator)
@Html.EditorFor(model => model.Request.Investigator)
@Html.ValidationMessageFor(model => model.Request.Investigator)
@Html.LabelFor(model => model.Request.Department)
@Html.EditorFor(model => model.Request.Department)
@Html.ValidationMessageFor(model => model.Request.Stage)
@Html.LabelFor(model => model.Request.Comment)
@Html.EditorFor(model => model.Request.Comment)
@Html.ValidationMessageFor(model => model.Request.Comment)
</div>
@Html.HiddenFor(model => model.Request.RequestID)
@Html.HiddenFor(model => model.Request.DateCreated)
@Html.HiddenFor(model => model.Request.CreatedBy)
</fieldset>
}
<p>
<input type="submit" value="Submit" />
</p>
</body>
Nothing happened if "submit" button is clicked. I even cold not put a breaking point at the line .
Thanks very much for your help.
Hugh