我有一个模型
public class SexModel
{
public SexModel()
{
this.Man = "Man";
this.Woman = "Woman";
this.ManId = 1;
this.WomanId = 2;
this.WomanSelected = this.ManSelected = false;
}
public bool ManSelected { get; set; }
public bool WomanSelected { get; set; }
public string Man { get; set; }
public string Woman { get; set; }
public int ManId { get; set; }
public int WomanId { get; set; }
}
在我的视图上创建一个单选按钮
@Html.RadioButton(Model.Man, Model.ManId, Model.ManIsSelected,
new { @id = Model.ManId})
@Html.RadioButton(Model.Man, Model.WomanId, Model.WomanSelected,
new { @id = Model.WomanId })
用户可以在注册表单上选择男性或女性单选按钮,但为什么在我的操作中单击提交表单按钮后,WomanSelected 和 ManSelected 总是错误的?