Donate

Blazor - Not All Code Paths Return A Value In Lambda Expression Of Type 'RenderFragment In Code Behind

Hello,

When I was transferring the C# Rendering Fragment snippet from the razor component to the code-behind class, I encountered this error which is "Not All Code Paths Return A Value In Lambda Expression Of Type 'RenderFragment<string> as presented on the code below.
@code{
     private RenderFragment<string> intro = text => @<h3>@text</h3>;
}
Afer reading the docs, this issue can be fixed in the code behind csharp class, by using the AddMarkUpContent() method builder parameter which will add HTML tags with content to the component as the delegate function of the RenderFragment object.
private RenderFragment<string> intro = (text) => builder =>
{
    builder.AddMarkupContent(0, $"<h3>{text}</h3>");
};
Blazor - Not All Code Paths Return A Value In Lambda Expression Of Type 'RenderFragment<string> In Code Behind


Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Bootstrap Modal In ASP.NET MVC With CRUD Operations