In particular, you need to use C# code to describe a DIV tree with all of its sets of attributes and child elements. While this adds a lot of flexibility, any change also requires a compile step. The problem is that the transformation and markup composition must be expressed in code. A tag helper, in fact, is a plain C# class that inherits from the base class TagHelper and overrides a single method. It turns some ad hoc non-HTML markup into Bootstrap-specific markup for modal dialog boxes (see bit.ly/2RxmWJS).Īny transformation between the input markup and the desired output is performed via C# code. In my book, “Programming ASP.NET Core” (Microsoft Press, 2018), I present a sample tag helper that does nearly the same job discussed earlier. In doing so, I’ll deal with Blazor-templated components and cascading parameters. In this article, I’ll build a new Blazor component that presents a modal dialog box through the services of the Bootstrap 4 framework. Tag helpers are great, but still present some programming wrinkles that Blazor components brilliantly iron out. With tag helpers the amount of code snippets decreases significantly. All of the branches you may face while creating a complex, made-to-measure chunk of HTML are handled in code, and all that developers write in text files is plain markup. A tag helper is a C# class instructed to parse a given markup tree to turn it into valid HTML5. In ASP.NET Core you can reach unprecedented levels of expressivity through new language artifacts called tag helpers. While the core concept behind Blazor is to leverage C# and Razor to build SPA applications, one aspect clearly inspired by other frameworks is the use of components.īlazor components are written using the Razor language, in much the same way that MVC views are built, and this is where things get really interesting for developers. Volume 34 Number 3 Hierarchical Blazor ComponentsĪs the latest framework to join the single-page application (SPA) party, Blazor had the opportunity to build on the best characteristics of other frameworks, such as Angular and React.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |