Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use TagHelpers in Blazor?

I created a tag helper and wanted to use that in my Blazor sample project. However, when I want to use the tag helper, the compiler complains about that:

CS0103 The name 'StartTagHelperWritingScope' does not exist in the current context FirstBlazorApp.

What is additionally required to make tag helpers work in Blazor?

like image 210
Sebastian P.R. Gingter Avatar asked Mar 20 '18 16:03

Sebastian P.R. Gingter


2 Answers

Update: Integrating Razor components into Razor Pages and MVC apps in a hosted Blazor WebAssembly app is supported in ASP.NET Core in .NET 5.0 or later. (Microsoft Docs)

Tag helpers are not supported in Blazor. At least not as of now.

like image 59
Sebastian P.R. Gingter Avatar answered Sep 17 '22 14:09

Sebastian P.R. Gingter


On A blazor page you would use a blazor component, this is like a TagHelper but it runs client side and is like an Angular component (or similar in any other client side JS framework) is that respect. TagHelpers run on the Server and blazor components run on the client, both allow you to create new tags. a simple component in the blazor same is the NavMenu which lives currently in the Shared folder.

like image 22
Wizzard Avatar answered Sep 17 '22 14:09

Wizzard