I try to reuse HTML snippets in my razor page (view component) but somehow it never call or hit the break in the html section.
I'm using Asp.net core 2.2
@{
Func<CategorySimpleModel, Microsoft.AspNetCore.Html.IHtmlContent> DisplayManufacturerPicture=
@<div class="col-sm-4">
<div class="row">
@foreach (var m in item.Manufacturers)
{
<div class="col-md-6 col-sm-12">
blah blah
</div>
}
</div>
</div>;
}
@foreach (var root in Model.Categories)
{
DisplayManufacturerPicture (root);
}
somehow it only works with @ though the method call is inside the server side syntax
@if (root.Manufacturers.Count > 0)
{
@DisplayManufacturerPicture(root);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With