2012-06-27 63 views
1

我想獲得與mvc jquery移動創建一個單選按鈕組。使用jQuery與mvc3移動單選按鈕

這是我

<li data-role="fieldcontain"> 
     <fieldset data-role="controlgroup" data-type="horizontal" data-mini="true"> 
      <legend>Gender:</legend> 
     @* <input type="radio" name="radio-choice-b" id="radio-choice-c" value="on" checked="checked" /> 
      <label for="radio-choice-c">Male</label> 
      <input type="radio" name="radio-choice-b" id="radio-choice-d" value="off" /> 
      <label for="radio-choice-d">Female</label> 
     *@ 
      @Html.LabelFor(model=>model.Consumer.IsMale,"Male") 
      @Html.RadioButtonFor(model => model.Consumer.IsMale, "True",new {value="on",@checked = "checked"}) 
      @Html.LabelFor(model=>model.Consumer.IsMale,"Female") 
      @Html.RadioButtonFor(model => model.Consumer.IsMale, "False", new {value="off"}) 
      </fieldset> 
    </li> 

這看起來像

enter image description here

它不可點擊,正如你可以看到有「男」按鈕中的單選按鈕。

我在做什麼錯?

回答

2

我綁定了我的單選按鈕列表錯誤。如果其他人有相同的問題,這是正確的方法

@Html.RadioButtonFor(model => model.Consumer.IsMale, true,new {value="on",@checked = "checked",id="Consumer_IsMale_true"}) 
<label for="Consumer_IsMale_true">Male</label> 

@Html.RadioButtonFor(model => model.Consumer.IsMale, false, new {value="off",id="Consumer_IsMale_false"}) 
<label for="Consumer_IsMale_false">Female</label>