Wednesday, May 23, 2012

How to check the radio button in mvc 3 when its bounded to a single boolean value

Hi
Here i'll tell you how to check the radio button in mvc 3 when its bounded to a single boolean value.

@Html.RadioButtonFor(model => model.ContactType, "False", new { value = "Direct" })
 @Html.RadioButtonFor(model => model.ContactType, new { value = "Mail" })
 @Html.RadioButtonFor(model => model.ContactType, new { value = "Phone" })

Just pass the parameter "False" to your radio button and left others blank. If it does'nt work for you set all others "True" and any of them "False".

@Html.RadioButtonFor(model => model.ContactType, "False", new { value = "Direct" })
 @Html.RadioButtonFor(model => model.ContactType,"True", new { value = "Mail" })
 @Html.RadioButtonFor(model => model.ContactType, "True",new { value = "Phone" })


Thank You

No comments:

Post a Comment