<div class="firstColumn">
<% for (int rowCount = 0; rowCount < Model.TaskAttributes.Count; rowCount += 2)
{%>
<%= Html.EditorFor(model => model.TaskAttributes[rowCount]) %>
<%}
%>
</div>
So, I have this bit of code which works fine, but I'm unhappy with all the MVC mark-up.
The solution does not support Razor syntax yet, so I'm stuck with this syntax, but I'm wondering if it can be cleaned up at all.
What I was thinking should work is this:
<div class="firstColumn">
<% for (int rowCount = 0; rowCount < Model.TaskAttributes.Count; rowCount += 2)
{
Html.EditorFor(model => model.TaskAttributes[rowCount]);
}
%>
</div>
This does not render any EditorFor's to my page, though. It appears that the '<%=' before the editorFor is cruicial. Is there any way to express this without having to close and open tags?
@Html.EditorFor(model => model.TaskAttributes[rowCount]);.Response.Write. This is a raw dump of information into the response stream. You lose all validation and safety of the output and take total responsibility for it. I don't know that's worth losing a couple WebForms tags...