ASP.NET MVC > View - Form specific

Radio button in Razor view in ASP.NET MVC

How to create a radio button in the ASP.NET MVC view?


To create radio buttons, we can use @Html.RadioButton helper method. We need to ensure that the name of the radio buttons are same if we want to make them mutually exclusive.

@using (Html.BeginForm())
{
<text>
@Html.RadioButton("Active", "true") Yes
@Html.RadioButton("Active", "false", true) No
</text>
}


Despite the fact that we have @Html.RadioButtonFor , it is not so useful in this context as it only creates one radio button that is not going to be useful as if it is selected, you can’t de select it.

 Views: 40459 | Post Order: 28



Write for us






Hosting Recommendations