Loop append div and repeat
- by Diego Vieira
I have this code
<div class="round-3-top">
<div class="round-2-top">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
<div class="round-2-bottom">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
</div>
<div class="round-3-bottom">
<div class="round-2-top">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
<div class="round-2-bottom">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
</div>
But i want generate dynamically, how i do that?
Ex.: i have 4 rounds, this would be the generated code
<div class="round-4-top">
<div class="round-3-top">
<div class="round-2-top">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
<div class="round-2-bottom">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
</div>
<div class="round-3-bottom">
<div class="round-2-top">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
<div class="round-2-bottom">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
</div>
</div>
<div class="round-4-bottom">
<div class="round-3-top">
<div class="round-2-top">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
<div class="round-2-bottom">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
</div>
<div class="round-3-bottom">
<div class="round-2-top">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
<div class="round-2-bottom">
<div class="round-1-top"></div>
<div class="round-1-bottom"></div>
</div>
</div>
</div>
I try using TagBuilder in MVC C# but I can not do. What should happen is, if you are 3 rounds, adding he should go inside each div is like the example above. Any idea how can I develop it?