视图:
@if (item.ReviewProject.DeclareState == DeclareOrReviewState.正在进行 && !item.IsSubmit)
{
@Html.ActionLink("编辑", "Edit", new { id = item.ApplicationProjectID }) |
@Html.ActionLink("删除", "Delete", new { id = item.ApplicationProjectID }) |
@* @Html.ActionLink("提交", "Submit", new { id = item.ApplicationProjectID })*@
提交 |
}
Javascript:
@section Scripts {
function submitApp(appid)
{
var choice = confirm("你确认提交吗?提交后将不可更改。");//确认框。
if (choice == true) {
$.post("/ApplicationProject/Submit/", { id: appid })
.success(function (data) {
alert("提交成功");
location.href = "/ApplicationProject/IndexForApplicator"; //跳转页面 //或者使用window.location.href="index/";
});
}
}
}
控制器的方法
//提交申报项目
[HttpPost]
public void Submit(string id)
{
var appProject = db.ApplicationProjects.Find(id);
appProject.IsSubmit = true;
db.SaveChanges();
// return RedirectToAction("IndexForApplicator");
}
原文:http://www.cnblogs.com/liuyuanhao/p/5591918.html