Let’s say I’ve this
public class OrganisationData
{
public NavigationData navigationData {get; set; }
}
Then
public class NavigationData
{
public string choice {get;set;}
//other properties omitted
}
I’ve this on my view
<% Using(Html.BeginForm()){%>
<p>
<% = Html.RadioButtonFor(x => x.organizationData.navigationData.choice, "1")%>
</p>
//More choices
<%}%>
The first the user gets to that view I want the first RadioButton to be pre-selected.
Thanks for helping.
you should set the value in the Model that you send to the viewengine, from your GET controller action.
something like:
Don’t put logic in the view as John suggests, this is a massive design antipattern and will only cause you woe in the long run.
Edit:
passing the default to the view from the controller means the controller has made the decision as to what the default is. This is logic and therefore doesnt belong in the view. Doing it in the controller makes it testable.