slandau
slandau

Reputation: 24102

Radio button checked with Html.RadioButtonFor

<%= Html.RadioButtonFor(m => m.AmortizationTermInYears, true, new { propertyName = "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.

Upvotes: 1

Views: 8708

Answers (2)

HaBo
HaBo

Reputation: 14327

you can also use

_checked="checked" 

this used to work before. But later on they @class = "checked" has become more of regular use.

Upvotes: 0

Chandu
Chandu

Reputation: 82943

Try this:

 <%= Html.RadioButtonFor(m => m.AmortizationTermInYears, true, 
         new { 
              propertyName = "AmortizationTermInYears", 
              onchange = "showAmortizationTermInYears();UpdateField(this);", 
              amortizationTermInYearsRadio = "true",
              checked="checked"
             }
     )
%>

Upvotes: 2

Related Questions