单选按钮仅在MVC中传递false。 [英] Radio buttons pass false only in MVC.

查看:57
本文介绍了单选按钮仅在MVC中传递false。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Radio Group但两者都只通过FALSE。







我尝试过:



I have Radio Group But both are pass FALSE Only.



What I have tried:

@Html.RadioButtonFor(model => model.NpdIndicator, new { @class = "radio-inline", @checked = "checked", id = "A" }, "Indicator")
                                                @Html.Label("Active")
                                                @Html.RadioButtonFor(model => model.NpdIndicator, new { @class = "radio-inline", @checked = "checked", id = "B" }, "Indicator")
                                                @Html.Label("InActive")

推荐答案

RadioButtonFor [ ^ ]方法是所选单选按钮的值。



您传递的是匿名对象,看起来更像是单选按钮的HTML属性。



更改代码以正确使用该方法。例如,假设 NdpIndicator 属性为 bool

The second parameter to the RadioButtonFor[^] method is the value of the selected radio button.

You are passing an anonymous object, which looks more like the HTML attributes for the radio button.

Change your code to use the method properly. For example, assuming the NdpIndicator property is a bool:
@Html.RadioButtonFor(model => model.NdpIndicator, true, new { @class = "radio-inline", id = "A" })
@Html.Label("A", "Active")
@Html.RadioButtonFor(model => model.NdpIndicator, false, new { @class = "radio-inline", id = "B" })
@Html.Label("B", "Inactive")


这篇关于单选按钮仅在MVC中传递false。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆