MVC3 点击页面的注册按钮没反应,调试Controller中的Register也没有调试到
用MVC3实现的
点击页面的注册按钮没反应,调试Controller中的Register也没有调试到
<div class="row">
@Html.LabelFor(model => model.Department)
@Html.EditorFor(model => model.Department)
@Html.ValidationMessageFor(model => model.Department)
</div>
<div class="row">
@Html.LabelFor(model => model.Telephone)
@Html.EditorFor(model => model.Telephone)
@Html.ValidationMessageFor(model => model.Telephone)
</div>
<div class="row">
@Html.LabelFor(model => model.Mobile)
@Html.EditorFor(model => model.Mobile)
@Html.ValidationMessageFor(model => model.Mobile)
</div>
<div class="row">
@Html.LabelFor(model => model.Address)
@Html.EditorFor(model => model.Address)
@Html.ValidationMessageFor(model => model.Address)
</div>
<div class="row">
@Html.LabelFor(model => model.Desc)
@Html.TextAreaFor(model => model.Desc)
@Html.ValidationMessageFor(model => model.Desc)
@Html.Hidden("Status",true)
</div>
<div class="row">
<input type="submit" value="注册" />
<a href="javascript:history.go(-1)">返回</a>
@*@Html.ActionLink("返回", "Index")*@
</div>
#region 注册用户
public ActionResult Register()
{
return View();
}
[HttpPost]
public ActionResult Register(FormCollection collection)
{
var user = new NalUser();
TryUpdateModel(user, collection);
if (ModelState.IsValid)
{
acc.AddUser(user);
acc.SaveChanges();
}
return RedirectToAction("Index");
}
#endregion
这个没问题的 不用去过多考虑。 主要是看你的提交按钮是否能够提交到指定页面去 ,建议用JS 试一下。