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.
parent child data

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

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -