Radio button checked with Html.RadioButtonFor
<%= Html.RadioButtonFor(m => m.AmortizationTermInYears, true, new { pr开发者_StackOverflowopertyName = "AmortizationTermInYears", onchange = "showAmortizationTermInYears();UpdateField(this);", amortizationTermInYearsRadio = "true" })%>
How do I tell this helper to check this radio button. I tried adding true
after the true
I already specified (which is the value not the isChecked
) paramater, but that didn't compile, it said no RadioButtonFor()
definition has those 4 parameters specified.
Try this:
<%= Html.RadioButtonFor(m => m.AmortizationTermInYears, true,
new {
propertyName = "AmortizationTermInYears",
onchange = "showAmortizationTermInYears();UpdateField(this);",
amortizationTermInYearsRadio = "true",
checked="checked"
}
)
%>
you can also use
_checked="checked"
this used to work before. But later on they
@class = "checked"
has become more of regular use.
精彩评论