javascript提交示例
<td>
@Html.ActionLink("编辑", "Edit", new { id = 1 }) <text> |</text>
@Html.ActionLink("删除", "Delete", new { id = 2 })<text> |</text>
<a href="javascript:submitApp('id')" class="submitapp">提交</a><text> |</text>
@section Scripts {
<script>
function submitApp(appid) {
var choice = confirm("你确认提交吗?提交后将不可更改。");//确认框。
if (choice == true) {
$.post("/Sub/", { id: appid })
.success(function (data) {
alert("提交成功");
location.href = "/ApplicationProject/Index";
});
}
}
</script>
}
控制器的方法
[HttpPost]
public void Sub(string id)
{
var appProject = db.ApplicationProjects.Find(id);
appProject.IsSubmit = true;
db.SaveChanges();
// return RedirectToAction("Index");
}