Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Mudblazor: Login dialog shows no controls

$
0
0

I want to build a server-side website with Mudblazor and C# .NET9. I need help displaying a dialog. The goal is to be able to log in. So you enter your username and password in the dialog and these two strings are passed on.The problem is that the dialog is displayed very small, without text boxes and buttons.
mini-sized dialog without controls
What am I doing wrong?

in LoginDialog.razor

@inject IDialogService DialogService@using MyNamespace.UserRepo;@using Microsoft.AspNetCore.Components@using MudBlazor<MudDialogProvider /><MudDialog @bind-IsOpen="_isOpen"><MudDialogTitle>Login</MudDialogTitle><MudDialogContent><MudTextField @bind-Value="_username" Label="Username" Required="true" Adornment="Adornment.Start" AdornmentIcon="mdi-account" /><MudTextField @bind-Value="_password" Label="Password" Required="true" Password="true" Adornment="Adornment.Start" AdornmentIcon="mdi-lock" /></MudDialogContent><MudDialogActions><MudButton OnClick="PerformLogin">Log in</MudButton><MudButton OnClick="CloseDialog">Cancel</MudButton></MudDialogActions></MudDialog>@code {    // [CascadingParameter] MudDialogInstance MudDialog { get; set; }    private bool _isOpen = true;    private string _username = "";    private string _password = "";    public void OpenDialog()    {        _isOpen = true;        StateHasChanged();    }    private void CloseDialog()    {    }    internal async Task PerformLogin()    {        UserRepo.Models.User? loggedInUser = await UserRepo.Loader.LoadUsers(_username, _password);        CloseDialog();    }}

in MainLayout.razor

@inherits LayoutComponentBase@using MudBlazor@inject IDialogService DialogService<MudThemeProvider Theme="@_theme" IsDarkMode="_isDarkMode" /><MudPopoverProvider /><MudDialogProvider /><MudSnackbarProvider /><MudLayout><MudAppBar Elevation="1" Dense=true style="@($"background: {(_isDarkMode ? Colors.LightBlue.Darken4 : Colors.Amber.Lighten5)} !important;")"><MudText Typo="Typo.h5" Class="ml-3" style="@($"color: {(_isDarkMode ? Colors.Gray.Lighten5 : Colors.Brown.Darken4)} !important;")">My Name</MudText><MudSpacer /> @* right side *@<MudButton OnClick="ShowLoginDialog" Variant="Variant.Outlined" Color="Color.Primary" Style="box-shadow: 0px 0px 8px rgba(0,0,0,0.3)">Log in</MudButton><MudButton OnClick="LogOut" Variant="Variant.Outlined" Color="Color.Primary" Style="box-shadow: 0px 0px 8px rgba(0,0,0,0.3)">Log out</MudButton><MudIcon Icon="@(_isDarkMode ? Icons.Material.Filled.DarkMode : Icons.Material.Filled.LightMode)" Size="Size.Medium" /><MudSwitch T="bool" @bind-Value="_isDarkMode" Color="Color.Primary" /></MudAppBar><CascadingValue Value="_isDarkMode">        @Body></CascadingValue></MudLayout>@code {    private void ShowLoginDialog(MouseEventArgs args)    {        var parameters = new DialogParameters<LoginDialog>();        DialogService.Show<LoginDialog>("", parameters);    }    private void LogOut()    {    }}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>