开发者

Radio button checked with Html.RadioButtonFor

开发者 https://www.devze.com 2023-02-27 12:02 出处:网络
<%= Html.RadioButtonFor(m => m.AmortizationTermInYears, true, new { pr开发者_StackOverflowopertyName = \"AmortizationTermInYears\", onchange = \"showAmortizationTermInYears();UpdateField(this);\
<%= 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消