Hi,
I've received this error.
/Users/jackptoke/Coding/BlazorApps/TokeHRM.Server/TokeHRM.Server/Pages/EmployeeOverview.razor(46,46): Error CS0029: Cannot implicitly convert type 'Microsoft.AspNetCore.Components.ElementReference' to 'TokeHRM.Server.Components.AddEmployeeDialogBase' (CS0029) (TokeHRM.Server)
I can't figure out the issue. I know that the issue at the last line of the Blazor component.
```C#
### **Here is the Blazor Component.**
```C#
@page "/employeeoverview"
@inherits EmployeeOverviewBase
<h1 class="page-title">All Employees</h1>
@if(Employees == null)
{
<p><em>Loading ...</em></p>
}
else
{
<table>
<thead>
<tr>
<th></th>
<th>Employee Id</th>
<th>First name</th>
<th>Last name</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach(var employee in Employees)
{
<tr>
<td><img src="@($"https://gillcleerenpluralsight.blob.core.windows.net/person/{employee.EmployeeId}-small.jpg")" class="rounded-circle" /></td>
<td>@employee.EmployeeId</td>
<td>@employee.FirstName</td>
<td>@employee.LastName</td>
<td>
<a href="@($"employeedetail/{employee.EmployeeId}")" class="btn btn-primary table-btn">
<i class="fas fa-info-circle"></i>Detail
</a>
<a href="@($"employeeedit/{employee.EmployeeId}")" class="btn btn-primary table-btn">
<i class="fas fa-edit"></i>Edit
</a>
</td>
</tr>
}
</tbody>
</table>
}
<button @onclick="@QuickAddEmployee" class="bn btn-dark table-btn quick-add-btn"> + </button>
<AddEmployeeDialog @ref="AddEmployeeDialog" ></AddEmployeeDialog>
``` C#
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using TokeHRM.Server.Services;
using TokeHRM.Shared;
using System.Linq;
using TokeHRM.Server.Components;
namespace TokeHRM.Server.Pages
{
public class EmployeeOverviewBase : ComponentBase
{
[Inject]
public IEmployeeDataService EmployeeDataService { get; set; }
protected AddEmployeeDialogBase AddEmployeeDialog { get; set; }
protected override async Task OnInitializedAsync()
{
Employees = (await EmployeeDataService.GetAllEmployees()).ToList();
}
public IEnumerable<Employee> Employees { get; set; }
protected void QuickAddEmployee()
{
AddEmployeeDialog.Show();
}
public async void AddEmployeeDialog_OnDialogClose()
{
Employees = (await EmployeeDataService.GetAllEmployees()).ToList();
StateHasChanged();
}
}
}
```
Can you create an issue from the doc page? That will connect the doc to the issue. Go to the bottom of the page and select This page .
It seems to set a reference to the Components namespace in the _imports.razor file.
In _Imports.razor
add: @using "Components namespace"
For example: if you created the AddEmployeeDialogBase.cs
component in a folder names _Components_ under _TokeHRM.Server_ project, just add: @using TokeHRM.Server.Components
in _Imports.razor
.
Most helpful comment
It seems to set a reference to the Components namespace in the _imports.razor file.
In
_Imports.razor
add:@using "Components namespace"
For example: if you created the
AddEmployeeDialogBase.cs
component in a folder names _Components_ under _TokeHRM.Server_ project, just add:@using TokeHRM.Server.Components
in_Imports.razor
.