【发布时间】:2018-04-07 17:02:52
【问题描述】:
所以我面临这个问题,我不记得如何解决它,但我确信它需要一些手工来通过使用 razor(不带 jquery)来实现它
基本上你有
型号
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;}
}
控制器
[HttpPost]
public ActionResult Save (MyModel model)
类选项
public class Option {
public String Name {get; set;}
public Guid Id {get; set;}
}
问题:
我想要一个绑定到“选项”属性的复选框列表,但是当我提交表单时,我想只检索选定值的 IDS,如果我可以将它们放在“SelectedIds”中会很棒属性。
有什么办法解决这个问题吗?
提前致谢。
【问题讨论】:
-
hmm,所以这种方法可能没有我的预期结果,但实际上是可以接受的。谢谢
标签: asp.net-mvc razor checkbox html-helper