2010-06-30 89 views

回答

16
<%: Html.RadioButtonFor(x => x.Gender, "Male", new { @checked = "checked" }) %> 

或呈现此视图控制器动作:

model.Gender = "Male"; 
return View(model); 
+1

对不起达林,这是行不通的。有没有其他解决方案? – SRA 2010-07-01 06:06:13

+1

确定它正在工作,我刚刚创建了一个示例ASP.MVC项目,将一个视图模型放入一个属性'Gender'(字符串类型),并在视图中使用HTML属性来设置'checked'属性。 – 2010-07-01 06:14:43

6

如果u使用Razor视图强,你可以使用使用单选按钮,这样

@Html.RadioButtonFor(model => model.PrintOrder, "Sequential", new {@checked="true"}) Sequential 

为您需要更正为 剃刀视图

@Html.RadioButtonFor(x => x.Gender, "Male", new { @checked = "checked" }) 

.aspx的视图

<%: Html.RadioButtonFor(x => x.Gender, "Male", new { @checked = "checked" }) %>