Reputation: 7121
I want to set different ids.
The first one will be: id1
the second: id2.
till ths last: id6.
how can I do that?
@for (int i = 0; i < 7; i++) {
<img id="id + @i" src="img.jpg">
}
Upvotes: 0
Views: 81
Reputation: 612
Try this: Just use a loop for i = 1 to 6:
@for (int i = 1; i <= 6; i++) {
<img id="id + @i" src="img.jpg">
}
Upvotes: 0
Reputation: 17590
Try that:
@for (int i = 0; i < 7; i++) {
<img id='@("id" + i)' src="img.jpg">
}
Upvotes: 3