RadioButtonFor在ASP.NET MVC 2 [英] RadioButtonFor in ASP.NET MVC 2

查看:134
本文介绍了RadioButtonFor在ASP.NET MVC 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以提供如何正确使用Html.RadioButtonFor一个简单的例子?比方说,这是一个简单的场景,我的模型有一个名为性别的字符串属性。我想显示两个单选按钮:男性和女性

Can someone provide a simple example of how to properly use Html.RadioButtonFor? Let's say it's a simple scenario where my model has a string property named Gender. I want to display two radio buttons: "Male" and "Female".

什么是实现这一点的同时在编辑视图保持选定值最干净的方式是什么?

What is the most clean way to implement this while retaining the selected value in an Edit view?

推荐答案

<一个href=\"http://stackoverflow.com/questions/2512809/has-anyone-implement-radiobuttonlistfort-for-asp-net-mvc/2590001#2590001\">This在计算器上,提供RadioButtonListFor和回答问题的交易解决你的问题太(@Larsenal它还包括了属性标签)

This question on StackOverflow deals with RadioButtonListFor and the answer addresses your question too (@Larsenal it also includes labels with the "for" attribute)

这篇关于RadioButtonFor在ASP.NET MVC 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆