i have edit form has label , current values in textbox, want check if values in form has been changed when form submitted. here form
<fieldset> <legend>module <small>edit</small></legend> @using (html.beginform("edit", "module")) { @html.validationsummary(true) @html.hiddenfor(m=>m.id) for(var = 0; < 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> this results

how can check if form has been changed? httppost method of controller this
[httppost] public actionresult edit(editmodule module) { if (modelstate.isvalid) { _repository.savemoduleedits(module); information("module edited!"); return redirecttoaction("modulelist", "module", new {area = "hardware"}); } error("edit unsuccessful, if problem persists please contact admin!"); return redirecttoaction("modulelist", "module", new { area = "hardware" }); } }
it straight forward on client side if using knockout. here article describes how use knockout change tracking. article uses knockout add-on called kolite make simpler.
Comments
Post a Comment