我试图从给定的选项中选择几个选项,然后将选择的选项发送回控制器。
The view (image) is something like this:
我遇到的问题是这些值不会发送回控制器。我可以将项目从一个ListBox
移动到另一个....
@Html.ListBoxFor(model => model.participantes, Model.participantes.Select(x => new SelectListItem { Text = x.nombre, Value = x.id.ToString() }), new { id = "listBoxSeleccionados", style = "width: 180px; height: 200px; resize: none;" })
....
@Html.ListBoxFor(model => model.posiblesparticipantes, Model.posiblesparticipantes.Select(x => new SelectListItem { Text = x.nombre, Value = x.id.ToString() }), new { id = "listBoxPosibles", style = "width: 180px; height: 200px; resize: none;" })
。
代码如下:
查看
public ActionResult Create()
{
....
prueba.posiblesparticipantes = Pers.listaPersonaParticipantes();
prueba.participantes = new List<ModeloPersona>();
return View(prueba);
}
public ActionResult Create(createCurso_prueba model, FormCollection collection)
{
try
{
}
catch
{
return View();
}
}
控制器
public class createCurso_prueba
{
....
public List<ModeloPersona> posiblesparticipantes { get; set; }
public List<ModeloPersona> participantes { get; set; }
....
}
模型
private int Judge(int Speed, int ViolationLimit, int SpeedLimit, int ExceedInstance) {
if (Speed>=1 && Speed=<SpeedLimit) {
ExceedInstance += 1;
}
return ExceedInstance;
}