Knockout MVC with existing C# code - looping
问题 The code in my view - @{ int tabIndex = 0; } @using (var metricGroup = ko.Foreach(m => m.MetricGroups)) { tabIndex++; <div id="tabs-@tabIndex" > ... </div> } The issue here is for all the divs rendered, the id is always the same - "tabs-1" instead of that, it should be "tabs-1", "tabs-2", "tabs-3" ... Can anyone please help me out with this issue? I have a highly complex view and Knockout MVC is driving me crazy 回答1: Because of the ko.Foreach your HTML will be generated on the client side ,