2013-05-02 62 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