html - What is the standard method for posting variable length child deletions to an asp.net MVC application? -
i have form 1 many relationship. this, person can have multiple addresses.

i want allow user delete address. without using ajax, typical method posting appropriate model's identification server?
what drawbacks attempting this?
the "delete" button included in editor template displays child model. able include correct model's id in button's value , post it.
<button type="submit" name="action" value="@model.addressid">delete</button> then, in main edit view, include "submit" button, has same name.
<input name="action" type="submit" value="edit"/> and, last, controller:
[httppost] [validateantiforgerytoken] public actionresult edit(personviewmodel person, string action) { if (modelstate.isvalid) { if(editsubmit == "edit") { //update models } else { // delete child models id == action } db.savechanges(); return redirecttoaction("index"); } return view(addressedited); } i doing learning exercise. realize that, posting data structure, people using javascript, , framework, organize , post data via ajax.
Comments
Post a Comment