2013-05-02 34 views
2

我需要从这些选项框选择的值传递到“列表”视图传递值

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; } 
} 

回答

1

假设你有一个提交按钮,发布到该动作,您只需更新控制器即可将模型作为参数并将其传递给下一个视图:

[HttpPost] 
public ViewResult SmokingEnvironments(Screen model) 
{ 
    return View("List", model); 
} 
+0

如果视图位于另一个名为Results的文件夹中,该怎么办? – user2224493 2013-05-02 19:53:15

+0

@ user2224493这是什么意思? – asawyer 2013-05-02 19:55:56

+0

return View(“〜/ Views/Results/List.aspx”,model); – user2224493 2013-05-02 19:56:53