

The dialog is rendered when the Index component is accessed in a browser. When the Dialog component is added to the Index component, IntelliSense in Visual Studio speeds development with syntax and parameter completion. The Dialog component's text ( ChildContent) are set by the content of the element. The tag's Title attribute passes a value for the title to the Dialog component's Title property. In the following example, the Index component ( Pages/Index.razor) uses the preceding Dialog component. The Dialog component is nested within another component using an HTML tag. The dialog's text ( ChildContent) and title ( Title) are provided by the following component that uses this component in its UI. In the preceding example, OnYes is a C# method triggered by the button's onclick event. The following Razor markup demonstrates a component ( Dialog.razor) that displays a dialog and processes an event when the user selects a button: Ĭonsole.WriteLine("Write to the console in C#! 'Yes' button selected.") Unlike Razor Pages and MVC, which are built around a request/response model, components are used specifically for client-side UI logic and composition.īlazor uses natural HTML tags for UI composition. Razor allows you to switch between HTML markup and C# in the same file with IntelliSense programming support in Visual Studio.

Razor is a syntax for combining HTML markup with C# code designed for developer productivity.

Components in Blazor are formally referred to as Razor components, informally as Blazor components. The component class is usually written in the form of a Razor markup page with a.
