2011-04-21 29 views
1
<%= Html.RadioButtonFor(m => m.AmortizationTermInYears, true, new { propertyName = "AmortizationTermInYears", onchange = "showAmortizationTermInYears();UpdateField(this);", amortizationTermInYearsRadio = "true" })%> 

如何讓這個幫助者檢查這個單選按鈕。我試過,我已經指定了true後加入true(這是價值不isChecked)paramater,但沒有編譯,它說沒有RadioButtonFor()定義有指定的4個參數。用Html.RadioButtonFor檢查的單選按鈕

+0

與標籤C#或ASP.NET MVC – Serghei 2011-04-21 18:06:52

回答

2

試試這個:

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

您的問題不加編譯標籤。給出一個語法錯誤期待「(」 – slandau 2011-04-21 20:11:59

+4

@slandau嘗試'@ checked',而不是'checked', 「檢查」是一個C#關鍵字,所以每畝之前使用''@符號(類似於'@class設置類') – 2011-08-08 09:21:44

0

你也可以使用

_checked="checked" 

此使用前工作。但後來他們 @class = "checked"已成爲更多的經常使用。