-
Notifications
You must be signed in to change notification settings - Fork 0
Components
Zach Sanford edited this page Nov 4, 2022
·
3 revisions
One of the benefits of using .NET's Blazor Server (and Blazor WASM for that matter) is the use of components. Components are reusable chunks of code that can be called in one line. They also can accept arguments in the form of parameters.
| File |
|---|
| ~\Staffify\Components\Modal.razor |
I created the modal component because it might be used more as the application grows. As of right now, I use it to give the user a confirmation that their changes were made when they update an employee record. It then redirects you back to the index page after confirmation. The component accepts four parameters.
[Parameter]
public string Title { get; set; } = "Modal Title";
[Parameter]
public string Body { get; set; } = "Modal Body Text";
[Parameter]
public string ButtonText { get; set; } = "Close";
[Parameter]
public string Route { get; set; } = "/";These parameters also contain defaults so I can call the component on a web page without explicitly adding parameters. Here I use it in the Employee Details page.
<Modal Title="Update Details" Body="The employee has been successfully updated" ButtonText="Close" Route="/" />
- π Home
- π’ Getting Started
- π About
- π Overview
- π₯οΈ Technologies
- π οΈ Builder
- π© Components
- πΎ Database
- π Overview
- π§ Setting Up
- π Interface
- βοΈ Class
- π Logging
- π Overview
- π Configuration
- π§βπ€βπ§ Models
- π Overview
- π§βπΌ Employee
- π AppSingletonData
- π Pages
- π Overview
- π Index
- π¨ββοΈ Employee Details
- π·ββοΈ About