Reputation: 918
How do I generate a label ID dynamically in ASP.NET MVC?
I was able to generate dynamic Ids for different TextBoxes using the following code:
<% for (int i = 1; i < 5; i++)
{%>
<div>
<%=Html.TextBox("F" + i, "", new { @class = "date", @value = "10/10/10", @style = "width:55px; color:#00467f ;" })%></div>
</div>
<%}%>
Upvotes: 0
Views: 1951
Reputation: 168
Have you tried something like this:
<label for="F<%=i.ToString()%>" id="label-id-<%=i.ToString()%>">Label text</label>
Upvotes: 1