By design, why was the value parameter of Html.RadioButton made as a type of object rather than string?
string RadioButton(this HtmlHelper htmlHelper, string name, object value);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s because a radio button could have any value and when the helper decides whether it should be checked or not it looks for a corresponding value in the model state.
For example:
and inside the controller you could pass integer value:
and the helper will automatically select the radio button. If you have a complex object it would use the
Convert.ToStringmethod.