【发布时间】:2014-08-07 20:21:25
【问题描述】:
我是 asp.net MVC 4 的新手。我在处理属性时遇到了一些问题
我在我的控制器中使用[httppost] 属性,但它不起作用
它甚至没有被调用
我的控制器
public ActionResult Inscription()
{
return View();
}
[HttpPost]
public ActionResult Inscription(Candidat candidat)
{
if (!ModelState.IsValid)
{
return View(candidat);
}
return RedirectToAction("Index");
}
我的看法
@model ProcRec.Models.Candidat
@{
ViewBag.Title = "Inscription";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@Html.ValidationSummary(true)
<div class="form_settings">
@using (Html.BeginForm("Inscription", "CandidatController"))
{
<table ="#FFFFFF">
<tr>
<td>@*<span >Nom :</span>*@ @Html.LabelFor(model => model.nom_candidat)</td>
<td> @Html.TextBoxFor(model => model.nom_candidat)
@Html.ValidationMessageFor(Model => Model.nom_candidat)
.
.
</table>
}
<input type="submit" class="submit right" value="Inscription" />
想你的帮助
【问题讨论】:
-
@Saranga ...我只是想完全回答这个问题..我发现了两个问题,所以我通过我的回答纠正了它们,提交按钮应该在我的回答中也有表格里面..我在安迪的回答之前回答了......谢谢......
标签: c# asp.net-mvc