i am passing models to radiobutton, how can i make one as default?
passing a model to radiobutton which has three different values for example
<%: Html:RadioButtonListFor(model=>model.Country, Model.Countries, new {@class="countrytype开发者_JAVA技巧"})%>
these countries has three values U.S, Canada, Other. But i want U.S to be selected by default. How can my do that?
my actionresult is :
public ActionResult Select(CountryModel m) { ... return View( new CountryModel ( countrytype.AsQuicklist()); }
how can i add model parameter in the return view?
RadioButtonListFor
is not a standard helper included in ASP.NET MVC. So the answer to this question will depend on where did you get this helper from and how it is implemented.
So a shot in the dark: you could try setting the corresponding model property in your controller action to the value of the button you want preselected:
public ActionResult Index()
{
SomeModel model = ...
model.Country = "Canada";
return View(model);
}
精彩评论