Live Chat Icon For mobile
Live Chat Icon

How do you define a render fragment using a Razor template in Blazor?

Platform: Blazor| Category: Templated components

Render fragments can be defined using Razor template syntax. The templated components can be rendered either using a Razor template with an argument or directly.

@page "/razor"

    RenderFragment template = @<p>The time is @DateTime.Now.</p>;
    RenderFragment<Employee> ItemTemplate = (item) => @<p>Employee name is @item.Name.</p>;


@code {
    Employee emp = new Employee { Name = "Test" };
    public class Employee
        public string Name;

Reference link:

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.