所以,我想改变我的复选框,已选中和未选中状态的单选按钮,说是,(选中)或否(未选中)。如何将我的复选框更改为单选按钮?
这里就是我所做的复选框:
笔者认为:
@Html.CheckBoxUi("PerpendicularCheckbox",@H.GetString("IsPerpendicular"), null, new { style = "margin-right:10px", @class = "type-style-paragraph" })
JS:
$('input:checkbox[name=PerpendicularCheckbox]').on({
"change": function() {
if (getUpdate()) {
var $this = $(this);
if (($this).is(':checked'))
$("ul li button").click();
}
}
});
if (!Perpendicular) {
$("#PerpendicularCheckbox").prop("checked", false);
}
else {
$("#PerpendicularCheckbox").prop("checked", true);
}
我想知道什么,我需要将其更改为单选按钮,是和没有选项,在asp.net mvc中使用html扩展?
编辑:
我在单选按钮loosy尝试:
@Html.RadioButtonForUi("PerpendicularCheckbox",@H.GetString("IsPerpendicular"), null, new { style = "margin-right:10px", @class = "type-style-paragraph" })
$('input:radio[name=PerpendicularCheckbox]').on({
"change": function() {
if (getUpdate()) {
var $this = $(this);
if (($this).is(':checked'))
$("ul li button").click();
}
}
});
RadioButtonForUi:
public static MvcHtmlString RadioButtonForUi<TModel, TProperty>(
this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TProperty>> expression,
string name,
bool IsEnable,
bool IsChecked,
object onchange = null,
string className = "",
bool isRequreid = true
) {etc.....}
使用它你的意思是这样的吗? https://msdn.microsoft.com/en-us/library/dd493075(v=vs.100).aspx – 2015-02-09 18:18:38
是的,但我只是想知道如何使用@ html.radiobutton选择是和不是为上面的复选框。 – 2015-02-09 18:21:09
为什么不使用@ Html.RadioButtonFor如果你需要单选按钮?! – oqx 2015-02-09 18:22:00