我正在尝试根据ViewBag中的roleId
使单选按钮被选中,但无论值是什么,单选按钮始终被选中。
以下是Razor代码:
<input type="radio" id="rdResident" class="userType" checked="@(ViewBag.roleId=="5"?"checked":"false")" />
我正在尝试根据ViewBag中的roleId
使单选按钮被选中,但无论值是什么,单选按钮始终被选中。
以下是Razor代码:
<input type="radio" id="rdResident" class="userType" checked="@(ViewBag.roleId=="5"?"checked":"false")" />
你只需要使用“checked”这个单词。尝试...
<input type="radio" id="rdResident" class="userType" @(ViewBag.roleId==5 ? "checked" : "") />