7
A
回答
10
如果使用HtmlHelper.RadioButton你会被罚款,只要你的名字属性名相匹配。
下面的代码来自我的一个项目一个片段:
<span><%= Html.RadioButton("DateFormat", "MMMM/dd/yy", Model.DateFormat.Equals("MMMM/dd/yy"), new Dictionary<string, object> { { "class", "normalwidth" } })%><label class="displayinline"><%=DateTime.Now.ToString("MMMM dd, yyyy")%></label></span>
<span><%= Html.RadioButton("DateFormat", "yyyy/MM/dd", Model.DateFormat.Equals("yyyy/MM/dd"), new Dictionary<string, object> { { "class", "normalwidth" } })%><label class="displayinline"><%=DateTime.Now.ToString("yyyy/MM/dd")%></label></span>
<span><%= Html.RadioButton("DateFormat", "dd/MM/yyyy", Model.DateFormat.Equals("dd/MM/yyyy"), new Dictionary<string, object> { { "class", "normalwidth" } })%><label class="displayinline"><%=DateTime.Now.ToString("dd/MM/yyyy")%></label></span>
<span><%= Html.RadioButton("DateFormat", "", new Dictionary<string, object> { { "class", "normalwidth" } })%><label class="displayinline">custom <%= Html.TextBox("customdate", "", new Dictionary<string, object> { { "style", "width:50px; font-size:12px; display:inline;" } }) %> </label></span>
这里是呈现的HTML。注意每个输入具有相同的名称,但值不同。只有选中的按钮才会将其值发回服务器。
<p><label>Date Format</label>
<span><input class="normalwidth" id="DateFormat" name="DateFormat" type="radio" value="MMMM/dd/yy" /><label class="displayinline">October 18, 2009</label></span>
<span><input checked="checked" class="normalwidth" id="DateFormat" name="DateFormat" type="radio" value="yyyy/MM/dd" /><label class="displayinline">2009/10/18</label></span>
<span><input class="normalwidth" id="DateFormat" name="DateFormat" type="radio" value="dd/MM/yyyy" /><label class="displayinline">18/10/2009</label></span>
<span><input class="normalwidth" id="DateFormat" name="DateFormat" type="radio" value="" /><label class="displayinline">custom <input id="customdate" name="customdate" style="width:50px; font-size:12px; display:inline;" type="text" value="" /> </label></span>
</p>
而在你的类:
public class Post
{
public string DateFormat {get; set:}
}
1
@Html.RadioButtonFor(m => m.DateFormat, "MMMM/dd/yy")
@Html.RadioButtonFor(m => m.DateFormat, "yyyy/MM/dd")
相关问题
- 1. KnockoutJs结合单选按钮
- 2. 带有html.radiobutton的单选按钮ASP.NET MVC
- 3. 怎么样与ASP.NET MVC的
- 4. ASP.NET MVC 5组单选按钮
- 5. asp.net mvc单选按钮列表
- 6. 单选按钮与行为结合到单一的财产
- 7. asp.net与单选按钮的多个gridviews
- 8. 用一个按钮提交多个单选按钮值ASP.NET MVC
- 9. 什么是ASP.NET MVC结合
- 10. ASP.NET中的单选按钮
- 11. 怎么办<html:radio>按钮的默认选择
- 12. 与单选按钮
- 13. ASP.NET MVC获取表单的动态单选按钮
- 14. asp.net mvc的复选框/单选矩阵模型结合
- 15. 试图找到选定的单选按钮。怎么了?
- 16. asp.net gridview单选按钮
- 17. ASP.Net单选按钮列表
- 18. asp.net单选按钮分组
- 19. 如果选项菜单按钮不在用户设备中,该怎么办?
- 20. ASP.Net 4.0中的单选按钮选择
- 21. 单选按钮,复选框值获得空在asp.net MVC提交
- 22. 根据单选按钮选择注入用户控件(ASP.NET MVC)
- 23. 制作用户在ASP.NET MVC中选择一个单选按钮
- 24. ASP.NET MVC复选框和单选按钮示例
- 25. ASP.NET MVC 5-如何选择单选按钮时上传文件?
- 26. 如何在ASP.NET MVC 2中预选一个单选按钮?
- 27. 问题与晚在asp.net mvc的结合
- 28. MVC单选按钮设计选项
- 29. MVC单选按钮被选中1
- 30. 根据单选按钮,我怎样才能有角度的子单选按钮?