2

我需要将从这些 Radioboxes 中选择的值传递给“列表”视图

.cshtml 文件

@Html.RadioButtonFor(m => m.SmokeHouse, 1)
@Html.RadioButtonFor(m => m.SmokeHouse, 0)

@Html.RadioButtonFor(m => m.SmokeCar, 1)
@Html.RadioButtonFor(m => m.SmokeCar, 0)

@Html.RadioButtonFor(m => m.SmokeWork, 1)    
@Html.RadioButtonFor(m => m.SmokeWork, 0)

[HttpPost]
public ViewResult SmokingEnvironments()
{
   return View("List");
}

班级

public class Screen
{
    public int SmokeCar { get; set; }
    public int SmokeHouse { get; set; }
    public int SmokeWork { get; set; }
}
4

1 回答 1

1

假设您有一个提交到该操作的提交按钮,您只需要更新您的控制器以将模型作为参数并将其传递给下一个视图:

[HttpPost]
public ViewResult SmokingEnvironments(Screen model)
{
   return View("List", model);
}
于 2013-05-02T19:43:53.610 回答