【发布时间】:2013-12-10 15:29:00
【问题描述】:
我有一个 razor 视图(Framework 4.5,MVC 5)和一个 html 输入 type=checkbox,其值等于模型布尔值,但它绑定“值”而不是 true 或 false。
这是我的代码:
for (int index = 0; index < Model.Item1.Locations.Length; index++)
{
WSTupleOfInt32StringStringBoolean location = Model.Item1.Locations[index];
<div class="editor-field">
<input id="@string.Format("presentation.ServiceInfoes[{1}].Locations[{0}].Key", index, Model.Item2)" type="checkbox" value="@location.ThirdValue" name="@string.Format("presentation.ServiceInfoes[{1}].Locations[{0}].ThirdValue", index, Model.Item2)" />
</div>
<div class="editor-label">
<label for="@string.Format("presentation.ServiceInfoes[{1}].Locations[{0}].Key", index, Model.Item2)">@location.FirstValue</label>
@if (!string.IsNullOrEmpty(location.SecondValue))
{
<a href="@string.Format("//maps.google.com/?q={0}", location.SecondValue)" target="_blank"><img alt="@location.SecondValue" src="@string.Format("//maps.google.com/maps/api/staticmap?center={0}&markers=color:blue|{0}&zoom=15&size=64x64&sensor=false", location.SecondValue)" /></a>
}
</div><br />
}
location.ThirdValue 是布尔属性,调试属性没问题.. 但在 HTML 中我得到value="value" 而不是value="false"。
发生了什么事?
【问题讨论】:
标签: c# html asp.net-mvc asp.net-mvc-4 razor