asp.net mvc LabelFor.在名称中使用数组时出错
public class ScheduleModel
{
[DisplayName("Example")]
public bool DayOff { get; set; }
}
public class SimpleModel
{
public List<ScheduleModel> ScheduleContainer { get; set; }
}
html
<%= Html.CheckBoxFor(m => m.ScheduleContainer[a].DayOff)%>
<%= Html.LabelFor(m => m.ScheduleContainer[a].DayOff)%>
它的代码生成
<input id="ScheduleContainer_2__DayOff" name="ScheduleContainer[2].DayOff" type="checkbox" value="true" />
<input name="ScheduleContainer[2].DayOff" type="hidden" value="false" />
<label for="ScheduleContainer[2]_DayOff">Example</label>
为什么 lablefor == ScheduleContainer[2]_DayOff 虽然应该是 ScheduleContainer_2__DayOff
public class ScheduleModel
{
[DisplayName("Example")]
public bool DayOff { get; set; }
}
public class SimpleModel
{
public List<ScheduleModel> ScheduleContainer { get; set; }
}
html
<%= Html.CheckBoxFor(m => m.ScheduleContainer[a].DayOff)%>
<%= Html.LabelFor(m => m.ScheduleContainer[a].DayOff)%>
It's code generate
<input id="ScheduleContainer_2__DayOff" name="ScheduleContainer[2].DayOff" type="checkbox" value="true" />
<input name="ScheduleContainer[2].DayOff" type="hidden" value="false" />
<label for="ScheduleContainer[2]_DayOff">Example</label>
Why lablefor == ScheduleContainer[2]_DayOff though should be ScheduleContainer_2__DayOff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 MVC 2 中的一个错误。它已在 MVC 3 中修复。
This is a bug in MVC 2. It has been fixed in MVC 3.