Avoid using batch inline script using <% %> inside any kind of loops in ASP.NET or MVC. I.e combining the .net server-side code with plain html code in a loop is not good for performance. Too much of batch inline scripts especially inside a loop will reduce the performance of the web application. It’s also not a good practice to use too much of server-side code with <% %>.
Example For batch inline script in a loop:
Below is an example of how to avoid batch inline script in the for loop shown above: