views:

60

answers:

1

I have a radio button list like this

<%=Html.RadioButtonFor(m => m.Gender,"Male")%> I should make this button selected by default.

Any inputs ??

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

or in the controller action that renders this view:

model.Gender = "Male";
return View(model);
Darin Dimitrov
Sorry Darin, This is not working. Is there any alternate solution ?
Sunil Ramu
Sure it is working, I've just created a sample ASP.MVC project, put a view model with a single property `Gender` (of type string), and in the view used HTML attributes to set the `checked` property.
Darin Dimitrov