I'm using a component from a third-party package, that accepts a RenderFragment as a parameter, and I want to assign a value to that RenderFragment through a Partial Class of my Index Page.
I realized that when I construct the RenderFragment in the code tags, it works. But once you put it in a partial class, Visual Studio starts flagging errors.
Example Code that works:
Razor File:
<Statistic Title="Feedback" Value="1128" PrefixTemplate="@prefix1" />
@code {
public RenderFragment prefix1 = @(<Icon Type = "like" />);
}
Example code that doesn't work:
Razor File:
<Statistic Title="Feedback" Value="1128" PrefixTemplate="@prefix1" />
Partial Class:
public partial class Index {
RenderFragment prefix1 = @(<Icon Type = "like" />);
}
So my question now is, how do I construct a render fragment in a partial class? I dont seem to find anything around this subject online.
Thanks in advance.