2

I am trying to make a popup in Blazor using Radzen and I believe this is not working because of dialogue service in the code section. Everything runs properly except when I click the button nothing pops up. How can I get it to work?

<RadzenDataGridColumn TItem="IDictionary<string, object>" Title="Modify">
                            <Template>
                                <RadzenButton ButtonStyle="ButtonStyle.Info" Icon="edit" 
                                    Class="m-1" Click=@EditSkill/>
                            </Template>
                        </RadzenDataGridColumn>
@code{
    async Task EditSkill()
    {
     await DialogService.OpenAsync("Edit Skill", ds =>
        @<RadzenCard>
          <div>
            <p class="mb-4">Skill ID <b>1</b></p>
            <div class="row">
                <div class="col">
                    <RadzenButton Text="Ok" Click="() => ds.Close(true)" Class="mr-1" 
                        Style="width: 80px;" />
                    <RadzenButton Text="Cancel" Click="() => ds.Close(false)" 
                        ButtonStyle="ButtonStyle.Secondary" Class="mr-1" />
                </div>
            </div>
        </div>
        </RadzenCard>);
    }
}
Zachhhh
  • 21
  • 4

1 Answers1

3

In order to use Dialog control from Radzen, you need to register it in your application's service collection and reference the component.

First, in Shared\MainLayout.razor add a reference to Dialog component:

<RadzenDialog/>

Then, for older version than .Net 6 use:

services.AddScoped<DialogService>();

In Startup.cs -> ConfigureServices method

For .Net 6 and after, use this in the program.cs -> Main method:

builder.Services.AddScoped<DialogService>();

Look into Radzen documentation here : https://blazor.radzen.com/get-started

Mauricio Atanache
  • 2,424
  • 1
  • 13
  • 18