c# - How do I build up an html string to display within a div using razor mvc? -



c# - How do I build up an html string to display within a div using razor mvc? -

i'm using razor mvc , want build html string can display within div, in php this:

$htmlstring = ''; foreach ($item $items) { $htmlstring .= '<p>'.$item.'</p>'; } <div> <? echo $htmlstring; ?> </div>

how equivalent in razor mvc?

you stick code within foreach loop on razor view

<div> @foreach ( var item in model.items ){ <p>@item</p> } </div>

assuming model pass in has property called items collection of type.

c# asp.net-mvc razor

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -