Ad

Search This Blog

Monday, January 2, 2023

Blazor Server - Add a component

 Each of the .razor files defines a UI component that can be reused.

Open the Index.razor file in Visual Studio. The Index.razor file already exists, and it was created when you created the project. It's located in the Pages folder inside the BlazorApp directory that was created earlier.

Add a Counter component to the app's homepage by adding a <Counter /> element at the end of the Index.razor file.


Pages/Index.razor

@page "/"

<PageTitle>Index</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

<SurveyPrompt Title="How is Blazor working for you?" />

<Counter />

Click the Hot Reload button to apply the change to the running app. The Counter component will then show up on the home page.



Source collected from  https://dotnet.microsoft.com/en-us/learn/aspnet/blazor-tutorial/add


No comments:

Post a Comment