C
C#10mo ago
Maskoe

Razor MVC UI reuse

I cant believe that I cannot figure this out, but how do I create the equivalent of a react or blazor component in MVC Razor? I have this code
<div class="form-group row">
<div class="col-md-3">
<nop-label asp-for="PimId" />
</div>
<div class="col-md-9">
<nop-editor asp-for="PimId" />
<span asp-validation-for="PimId" />
</div>
</div>
<div class="form-group row">
<div class="col-md-3">
<nop-label asp-for="PimId" />
</div>
<div class="col-md-9">
<nop-editor asp-for="PimId" />
<span asp-validation-for="PimId" />
</div>
</div>
That I want to turn into <SimpleEditor asp-for="PimId/> or something similiar. But I just cant find the right direction. ViewComponents? TagHelper? I think its more difficult because these are ModelExpressions. PimId comes from the Model of the original component. This has to be one of the most common reuse patterns to ever exist, but there is nothing online.
3 Replies
Want results from more Discord servers?
Add your server