在mvc中创建Radiobutton [英] creating Radiobutton in mvc

查看:54
本文介绍了在mvc中创建Radiobutton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的表格中创建3个radiobutton。



1. Bold

2.斜体

3.下划线

如何使用enum和viewbag生成三个?



请提供示例代码?

I want to create 3 radiobutton in my form.

1. Bold
2. Italic
3. Underline
How i generate three with enum and viewbag?

Please provide an example code?

推荐答案

MVC Enum RadioButtonList Helper [ ^ ]



查看此链接..
MVC Enum RadioButtonList Helper[^]

check this link..


查看此文章..

http://john.katsiotis.com/blog/asp.net-mvc-3---a-radiobuttonlist -for-enum-properties [ ^ ]

还有这些..

<小时ef =http://stackoverflow.com/questions/5660377/strongly-typed-radiobuttonlist> http://stackoverflow.com/questions/5660377/strongly-typed-radiobuttonlist [ ^ ]

http://stackoverflow.com/questions/11506570/mvc-3-helper-for-radiobuttonlist-enum [ ^ ]

http://jonlanceley.blogspot.com/2011/06/mvc3- radiobuttonlist-helper.html [ ^ ]
Check this article..
http://john.katsiotis.com/blog/asp.net-mvc-3---a-radiobuttonlist-for-enum-properties[^]
And also these..
http://stackoverflow.com/questions/5660377/strongly-typed-radiobuttonlist[^]
http://stackoverflow.com/questions/11506570/mvc-3-helper-for-radiobuttonlist-enum[^]
http://jonlanceley.blogspot.com/2011/06/mvc3-radiobuttonlist-helper.html[^]


试试这样

try like this
public class HomeController : Controller
   {
       //
       // GET: /Home/

       public ActionResult Index()
       {
           Array values = Enum.GetValues(typeof(RadioButton));
           ViewData["RadioButton"] = values;
           return View();
       }

       public enum RadioButton
       {
           Bold,
           Italic,
           UnderLine
       }

   }





从视图迭代如下所示





from the view iterate like below

@foreach (var prod in (Array)ViewData["RadioButton"])
{
    <input type="radio" name="RadioButton" value="male">@prod<br>
}
</br>





希望这有帮助



Hope this helps


这篇关于在mvc中创建Radiobutton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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