samedi 7 avril 2018

Is it possible to Submit a list of GUIDS with MVC based on checkbox?

So i'm facing this problem that I don't remember how to solve it, but i'm sure it needs some handcraft to achieve it by using razor (without jquery)

Basically you have

Model

public class MyModel {
    --Post will write here:
    public List<Guid> SelectedIds {get; set;}

    --This is the actual list of values, ids, etc...
    public List<Option> Options {get;}
}

Controller

[HttpPost]
    public ActionResult Save (MyModel model)

Class Option

public class Option {
    public String Name {get; set;}
    public Guid Id {get; set;}
}

Question:

I would like to have a list of checkboxes binded to "Options" property, but when I submit the form, I would like to retrieve IDS only of the selected values, would be great if I could put them inside "SelectedIds" property.

Any clue how to solve this?

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire