Reputation: 4131
In MVC 3, view-cshtml file, I want to create a dynamic id like below. How can I merge "videoItem_" and "@MenuItemIndex" to get "videoId_5" for example?
<div class='videoItem' id='videoItem_@MenuItemIndex'>
EDIT : I only need to add();
<div class='videoItem' id='videoItem_@(MenuItemIndex)'>
Thank you.
Upvotes: 1
Views: 3304
Reputation: 337560
Wrap the variable in brackets to make the expression explicit:
<div class='videoItem' id='videoItem_@(MenuItemIndex)'>
Upvotes: 3
Reputation: 35409
@for(int i = 0; i < SomeInteger; i++){
<div class='videoItem' id='videoItem_@(i)'>
}
Upvotes: 3