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

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

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -