剃刀单选按钮MVC [英] Razor radio button MVC

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

问题描述

<input id="@question.QuestionId" type="radio" value="@question.QuestionDescription" name="@string.Format("name_{0}", question.Group)" checked=@question.IsSelected"checked":false /> @question.QuestionDescription

根据复选框应选择或不选择的question.IsSelected值。

Depending on the question.IsSelected value the checkbox should be selected or not selected.

但不管真或假IsSelected属性的单选框始终检查。你能指出其中选中属性错误,请

But regardless of true or false of the IsSelected property Radiobutton is always checked. Can you point where the error in checked attribute please

推荐答案

如果你给它的检查属性将被托运设置任何东西。我会选择性地添加根据 IsSelected 属性整个检查='检查'价值,忽略它,当值假的。

If you give it anything for the checked attribute it will be set to checked. I would optionally add the entire checked='checked' value based on the IsSelected property, omitting it when the value is false.

<input id="@question.QuestionId" type="radio" value="@question.QuestionDescription" name="@string.Format("name_{0}", question.Group)" @(question.IsSelected?"checked='checked'":"") /> @question.QuestionDescription

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

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