我有一个编辑表单,它在文本框中有一个标签和当前值,我想检查提交表单时表单中的值是否已更改。这是表格
<fieldset>
<legend>Module <small>Edit</small></legend>
@using (Html.BeginForm("Edit", "Module"))
{
@Html.ValidationSummary(true)
@Html.HiddenFor(m=>m.Id)
for(var i = 0; i < Model.Properties.Count(); i++)
{
<label class="label">@Model.Properties[i].Name</label>
<div class="input-block-level">@Html.TextBoxFor(model => Model.Properties[i].Value, new { @value = Model.Properties[i].Value })</div>
}
<div class="form-actions" id="buttons">
<button type="submit" class="btn btn-primary" id="Submit">Save changes</button>
@Html.ActionLink("Cancel", "ModuleList", null, new { @class = "btn " })
</div>
}
</fieldset>
这导致
如何检查表格是否已更改?我的控制器的 httppost 方法目前看起来像这样
[HttpPost]
public ActionResult Edit(EditModule module)
{
if (ModelState.IsValid)
{
_repository.SaveModuleEdits(module);
Information("Module was successfully edited!");
return RedirectToAction("ModuleList", "Module", new {area = "Hardware"});
}
Error("Edit was unsuccessful, if the problem persists please contact admin!");
return RedirectToAction("ModuleList", "Module", new { area = "Hardware" });
}
}