asp.net-mvc – MVC和RadioButtonList
发布时间:2020-12-16 00:45:45 所属栏目:asp.Net 来源:网络整理
导读:我尝试这样做,但这只显示无旁边的单选按钮。 % foreach (string s in Html.RadioButtonList("rbl")) {% % =s %% } % 解决方法 Elijah Manor写了ASP.NET MVC 1.0中相同的麻烦: ASP.NET MVC Html.RadioButtonList Blues 他决定循环他的DataSource并创建单独
我尝试这样做,但这只显示无旁边的单选按钮。
<% foreach (string s in Html.RadioButtonList("rbl")) {%> <% =s %> <% } %> 解决方法
Elijah Manor写了ASP.NET MVC 1.0中相同的麻烦:
ASP.NET MVC Html.RadioButtonList Blues 他决定循环他的DataSource并创建单独的Html.RadioButton和Label组合。 <!-- After using and looking at the code for the Html.RadioButtonList in the ASP.NET MVC 1.0 RTM codebase,I'm not sure how it is supposed to be useful. It only outputs the actual input radio button and doesn't render any corresponding labels. To get around this I ended up writing a foreach creating individual Html.RadioButton and labels --> <% var radioButtonList = new SelectList(new List<ListItem> { new ListItem { Text = "Current",Value="false",Selected=true },new ListItem { Text = "Other",Value="true"}},"Value","Text","false"); var htmlAttributes = new Dictionary<string,object> { { "class","radioButtonList" },{ "onclick","if(eval(this.value)) { $('#tblDate').show('slow'); } else { $('#tblDate').hide('slow'); }" } }; foreach (var radiobutton in radioButtonList) { %> <%=Html.RadioButton("rblDate",radiobutton.Value,radiobutton.Selected,htmlAttributes)%> <label><%=radiobutton.Text%></label> <% } %> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – SignalR 2.0超时连接
- asp.net-core – ASP.Net核心RC1:System.ArgumentExceptio
- asp.net mvc 自定义pager封装与优化
- asp.net-mvc – Asp.Net MVC主题,如何?
- asp.net – 如何在gridview中将navigateurl添加到超链接
- asp.net-mvc – MVC – 索引视图溢出
- asp.net – FindControl()返回null
- 如何在ASP.NET中处理长时间运行的数据库查询
- asp.net-mvc – 使用Html.ActionLink传递文本框值
- ASP.NET MVC3中基于权限的授权
推荐文章
站长推荐
- asp.net – DropDownList获取底层对象
- asp.net-mvc – 如何首先使用EF核心代码创建连接
- asp.net – Page_Load中的Response.Redirect
- asp.net-mvc-3 – MVC3 / Razor添加控制器“Get-
- asp.net – SqlException(0x80131904):第28行:
- asp.net-mvc-5 – 我们也可以在Windows /桌面应用
- asp.net – 禁用web.config继承?
- asp.net-mvc – ASP.NET MVC中的非字符串角色名称
- 关于在asp.net mvc中实现忘记密码功能的一些问题
- asp.net – Azure网站上HTTP 1.0代理请求的gzip压
热点阅读