我有一个视图,它上面有一个单选按钮组。单选按钮的确与我的模型无关。它只是决定代码将采取什么路径(根据他们所做的选择调用哪个存储过程)。我如何获得控制器的选择值?使用剃须刀的单选按钮
事情是这样的:
<p>
Select the option describing what you want to do:
<br/>
<br/>
<label>@Html.RadioButton("selectProcess", "NewLetter", new { @id = "NewLetter" })Create a New Letter</label>
<br />
<label>@Html.RadioButton("selectProcess", "LetterInProgress", new { @id = "LetterInProgress" })Edit a Letter in Progress</label>
<br/>
<label>@Html.RadioButton("selectProcess", "GeneratedLetter", new { @id = "GeneratedLetter" })Edit a Letter that has been Generated</label>
<br/>
<label>@Html.RadioButton("selectProcess", "AppendGeneratedLetter", new { @id = "AppenGeneratedLetter" })Append a Generated Letter</label>
<input type="submit" value="Go" />
</p>
不知道我是否需要这些ID在这里,但我只是想在我的控制器接收所选择的值,并调用一个存储过程或其他的方法(如我的模型的一部分)...选定的选项不代表模型中的字段。
我不是一个很好的前端人员,所以我知道我可能会在这方面做得比较落后。
您应该使用具有属性'selectProcess'的视图模型并回发视图模型。否则,您将需要使用Request [“selectProcess”]来访问该值。是的,你应该给单选按钮和'ID'属性以避免无效的HTML(没有它们,'RadioButton()'方法将生成所有单选按钮'id =“selectProcess”' –