asp.net-mvc – MVC和RadioButtonList
发布时间:2020-05-29 19:32:28 所属栏目:asp.Net 来源:互联网
导读:我尝试这样做,但这只显示无旁边的单选按钮。 % foreach (string s in Html.RadioButtonList(rbl)) {% % =s %% } % Elijah Manor写了ASP.NET MVC 1.0中相同的麻烦: ASP.NET MVC Html.RadioButtonList Blues 他决定循环他的DataSource并创建单独的H
|
我尝试这样做,但这只显示无旁边的单选按钮。 <% 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-mvc – 使用Repository/Service Pattern和MVC时缓存
- 在Azure中为ASP.NET Core Web应用程序设置SQL连接字符串
- asp.net-mvc – 如何在ASP.NET MVC中生成完整的trace.axd?
- 在asp.net中的web.config的位置元素中有多个路径
- ASP.Net MVC路线映射
- 从ASP.Net页面通过C#将NetworkCredential传递给HttpWebRequ
- asp.net-mvc – 实体类型没有键定义 – 代码优先
- iis-7.5 – .NET MVC 3动作是否应该触发w3wp.exe以生成进程
- asp.net-mvc-4 – 在asp.net mvc 4模型中更改验证触发顺序
- asp.net – 使用SQLBulkCopy插入/更新数据库
推荐文章
站长推荐
热点阅读
