我非常熟悉MVC,尤其是Visual。在查找了C#中各种单选按钮的在线示例之后,我仍然无法看到它被翻译成VB。
有人能帮我简单地解释一下如何通过单选按钮来解释一个值吗?就是简单地传递一个整数0,1或2等等。然后我将在我的控制器中做一个if handle来处理它。
我一直在尝试这样的方法
@Html.RadioButton("ButtonName", "1", True) 然后我想把它拿回来,就像在控制器里
Dim selection As Integer = ...
If selection == 1 Then
etc...很抱歉解释的语法不好。用朴素的话说
<input type="radio" name="SomeName" value="1">
<input type="radio" name="SomeName" value="2"> 然后返回检查过的值。
非常感谢
发布于 2014-02-23 06:01:20
假设你的模型
public class YourModel{
int RadioValue{get;set;}
....
}你的观点
@using namspace;
@model YourModel
@using(Html.BeginForm(....)){
@Html.RadioButton("RadioValue", 1, True) @* The first parameter is name, and must match the name of the property you are binding to. *@
@Html.RadioButton("RadioValue", 2, False)
}你的控制器
public ActionResult(YourModel model)
{
//Get value
model.RadioValue....
}https://stackoverflow.com/questions/21963405
复制相似问题