Finding Repeater Type Functions in ASP.Net MVC

I use the Repeater control in regular ASP.Net web projects. I see that ASP.Net MVC does not have this type of thing. What should i use here?

EDIT:

In response to the question, what am I trying to do, what cannot I achieve in foreach. I guess I'm trying to get an alternating line style. In addition, he simply does not feel like having a presentation other than the markup in the view. But maybe I can handle it. Thanks for answers.

+4
source share
5 answers

The simplest task is the foreach .
What are you trying to do?

EDIT

 <% bool odd = false; foreach(var row in something) { %> <tr class="<%= odd ? "OddRow" : "EvenRow" %>"> ... </tr> <% odd = !odd; } %> 
+8
source

To add to the answer SLaks.

You can encapsulate your html in partial view.

Call <%= Html.Partial("ViewName", optional_ViewModel) %> .

This may be closer to repeater control. Where PartialView will look like your element template.

This approach also allows for very good reuse of code.

+1
source

If you missed out on many of the WebForms features, maybe you just need a richer viewer? Can I offer a Spark View Engine ? Like WebForms, there are many features, so you don’t need to rewrite the same material and / or write a bunch of your own helpers.

+1
source

alternating line style can be achieved by css styles ...
BTW - every functionality from web forms can be achieved in mvc ... in the end all html, js and css

0
source

You can even create an HTML helper for this.

0
source

Source: https://habr.com/ru/post/1303580/


All Articles