任何元素,我不知道爲什麼我會得到序列不包含任何元素還挺新的MVC序列包含MVC
我的控制器
[HttpPost]
public ActionResult DeleteAnnounce(string announce)
{
using (var db = new HarmonyMainServerDbContext())
{
ANNOUNCEMENT annoude = db.Announcer.First(c => c.AnnounceTitle == announce);
db.Announcer.Remove(annoude);
db.SaveChanges();
}
return RedirectToAction("ViewAnnounce");
}
我查看即時
<div id="clientDetailsContainer">
@using (Html.BeginForm("Announcements", "Admin", FormMethod.Post, new { id = "Announcers" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="module-controls" style="display:block;">
<a href="/Admin/ViewAnnounce" class="k-button module-action"><img src="../Images/src/back.png"/><span>Back to List</span></a>
<a class="k-button module-action" id="submitSave" title="haha"><img src="../Images/src/subgrid_save.png"/><span>Save</span></a>
<a class="k-button module-action" id="submitDelete" ><img src="../Images/src/subgrid_save.png"/><span>Delete</span></a>
</div>
<h2>Announcement</h2>
@Html.HiddenFor(model => model.AnnounceID)
<div class="client-details" style="margin-left: 50px">
<p>
<label class="label-ant">Announcement Title</label>
@Html.TextBoxFor(model => model.AnnounceTitle, new {@class="k-textbox", @style="width:250px" })
@Html.ValidationMessageFor(model => model.AnnounceTitle)
</p>
<p>
<label class="label-ant">Announcement Remarks</label>
@Html.TextBoxFor(model => model.AnnounceRemarks, new {@class="k-textbox", @style="width:250px" })
@Html.ValidationMessageFor(model => model.AnnounceRemarks)
</p>
<p>
<label class="label-ant">Announce Link</label>
@Html.TextBoxFor(model => model.AnnounceLink, new {@class="k-textbox", @style="width:250px" })
@Html.ValidationMessageFor(model => model.AnnounceLink)
</p>
</div>
}
<script>
$("#submitSave").click(function() {
$("#Announcers").submit();
});
$("#submitDelete").click(function() {
$("#Announcers").attr({
"action" : "/Admin/DeleteAnnounce",
});
});
</script>
</div>
因爲你的參數'announce'是一個或非項目'null'(查看從來帖子返回任何值) –