user2377475
user2377475

Reputation:

Adding a custom class to Radio Buttons in ASP.NET MVC 4

I'm trying to add Bootstrap classes to a set of radio buttons.

@Html.RadioButtonFor(model => model.Male, !Model.Male) Female
@Html.RadioButtonFor(model => model.Male, Model.Male) Male

Just don't seem to get the right way of doing it. Any help appreciated. Thanks

Upvotes: 4

Views: 14241

Answers (1)

Zabavsky
Zabavsky

Reputation: 13640

@Html.RadioButtonFor(model => model.Male, !Model.Male, new { @class = "female"})
@Html.LabelFor(model => model.Male, "Female", new { @class = "female"})

@Html.RadioButtonFor(model => model.Male, Model.Male, new { @class = "male"})
@Html.LabelFor(model => model.Male, "Male", new { @class = "male"})

Upvotes: 16

Related Questions