Home > OS >  How to make radio button from textbox code asp.net mvc
How to make radio button from textbox code asp.net mvc

Time:12-08

Hello i am working in asp.net mvc and i have this model done ready by the IDE the form is good and works it uploads the data on database. But insead of a textbox i want to make radio button. This is my code that makes the textbox:

 @Html.EditorFor(model => model.Gjinia, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Gjinia, "", new { @class = "text-danger" })

Anyone knows how to make a radio button that will still work when inserting in the database?

Thank you in advance.

CodePudding user response:

Instead of EditorFor you should use RadioButtonFor to change textbox into radiobutton.

For example: Male: @Html.RadioButton("Gender","Male")
Female: @Html.RadioButton("Gender","Female")

  • Related