ASP.NET MVC에서 foreach 루프 내의 체크 박스 세트의 tabindex 값을 어떻게 설정할 수 있습니까?ASP.NET MVC 뷰에서 foreach 루프에 tabindex를 설정하려면 어떻게해야합니까?
내 현재 솔루션은 Response.Write를 사용하여 체크 상자를 출력하지만, 나는 좀 더 우아한 것을 찾고 싶습니다.
누구에게 좋은 해결책이 있습니까?
이 코드는 작동하지 않습니다
<label for="country">
Country:
</label>
<%= Html.DropDownList("country", Model.Countries.OrderBy(x => x.Text), "Choose country...", new { tabindex = 8 })%><br />
<fieldset id="sales-processing-methodologies">
<legend>Sales Processing Methodology:</legend>
<% int i = 9;
foreach (var method in Model.ProcessingMethodologies)
{
%>
<input type="checkbox" id="<%=method.Key%>" name="processing-methodologies" class="checkbox" value="<%=method.Key%>" tabindex="<%i.ToString();%>"> </input>
<label for="<%=method.Key%>">
<%=method.Value%>
</label>
<% i++;
} %>
</fieldset>
을이 수행합니다
<label for="country">
Country:
</label>
<%= Html.DropDownList("country", Model.Countries.OrderBy(x => x.Text), "Choose country...", new { tabindex = 8 })%><br />
<fieldset id="sales-processing-methodologies">
<legend>Sales Processing Methodology:</legend>
<% int i = 9;
foreach (var method in Model.ProcessingMethodologies)
{
Response.Write(@"<input type=""checkbox"" id=""" + method.Key + @""" name=""processing-methodologies"" class=""checkbox"" value=""" + method.Key + @""" tabindex=""" + i.ToString() + @"""> </input><label for=""" + method.Key + @""">" + method.Value + @"</label>");
i++;
} %>
</fieldset>
편집 :의 tabindex = "" 생산 작동하지 않는 코드입니다.
왜 코드가 작동하지 않거나, 어떤 일이 발생하거나, 무엇이 생산됩니까? 그것은 나에게 완전히 잘못 보이지 않습니다. – Odd
진지하게, Response.Write의 문제점은 무엇입니까? –