user2224493
user2224493

Reputation: 269

Passing values between MVC Views

I need to pass the values selected from these Radioboxes to the "List" view

cshtml file

@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");
}

class

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

Upvotes: 2

Views: 443

Answers (1)

Ant P
Ant P

Reputation: 25221

Assuming you have a submit button that posts to that action, you just need to update your controller to take the model as a parameter and pass it to the next view:

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

Upvotes: 1

Related Questions