Q:

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

0

This code will help you to understand how to define a render fragment using a Razor template in Blazor.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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>;
}

@template
@ItemTemplate(emp)

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now