Mvc list modelbinding
I have a view that renders at list of people and a checkbox like this:
<% for (int i = 0; i < Model.ElevSelectedList.Count; i++) {%>
<tr>
<td>
<%=Html.CheckBoxFor(x => x.ElevSelectedList[i].Valgt, new { @class="elevSelect" }) %>
<%=Html.HiddenFor(x => x.ElevSelectedList[i].ElevId) %>
<%=Html.DisplayTextFor(x => x.ElevSelectedList[i].ElevCpr) %>
<%=Html.HiddenFor(x => x.ElevSelectedList[i].ElevCpr) %>
</td>
<td>
<%=Html.DisplayTextFor(x => x.ElevSelectedList[i].ElevKuvertNavn)%>
<%=Html.HiddenFor(x => x.ElevSelectedList[i].ElevKuvertNavn)%>
</td>
</tr>
<% } %>
this produces the correct input fields in the output, like this:
<tr>
<td>
<input checked="checked" class="elevSelect" id="ElevSelectedList_0__Valgt" name="ElevSelectedList[0].Valgt" type="checkbox" value="true" /><input name="ElevSelectedList[0].Valgt" type="hidden" value="false" />
<input id="ElevSelectedList_0__ElevId" name="ElevSelectedList[0].ElevId" type="hidden" value="112849" />
1003950000
<input id="ElevSelectedList_0__ElevCpr" name="ElevSelectedList[0].ElevCpr" type="hidden" value="1003950000" />
</td>
<td>
Anders Lind Ki开发者_JS百科rkely
<input id="ElevSelectedList_0__ElevKuvertNavn" name="ElevSelectedList[0].ElevKuvertNavn" type="hidden" value="Anders Lind Kirkely" />
</td>
</tr>
All this is working in development and when i deploy it to a local IIS however when it is deployed to production the html output look like this:
<tr>
<td>
<input checked="checked" class="elevSelect" id="Valgt" name="Valgt" type="checkbox" value="true" /><input name="Valgt" type="hidden" value="false" />
<input id="ElevId" name="ElevId" type="hidden" value="112849" />
1003950000
<input id="ElevCpr" name="ElevCpr" type="hidden" value="1003950000" />
</td>
<td>
Anders Lind Kirkely
<input id="ElevKuvertNavn" name="ElevKuvertNavn" type="hidden" value="Anders Lind Kirkely" />
</td>
</tr>
Here the name of the html output is diffrent, this makes the modelbinding fail without any error, in development and the local IIS we are running IIS 7.5 but production is IIS 7, the website is MVC2 running in an integrated application pool.
Has anyone encuntered this problem befor and have a solution?
We have never encountered something like this. But, its always advisable to maintain same version settings at both environments. Try changing the production IIS server to 7.5
精彩评论