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
Post a Comment