如何在控制器中获取选定的单选按钮值?

时间:2014-08-27 11:25:52

标签: asp.net-mvc

我正在使用mvc。我无法在控制器中获取单选按钮值。

 @Html.RadioButtonFor(model => model.SelecetdOption, m.Name, new {});

1 个答案:

答案 0 :(得分:0)

您可以在视图中看到类似内容:

<input type="radio" id="rbOption1" name="rbMyChoices" value="Option1" />
<input type="radio" id="rbOption2" name="rbMyChoices" value="Option2" />

然后在你的控制器中......

public actionresult MyAction(string rbMyChoices){
    if(rbDents == "Option1")...
    if(rbDents == "Option2")...
}

如果将rbMyChoices添加到控制器参数中,它将包含rbMyChoices rbgroup的选定值。

相关问题