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

Blazor Server EditForm requires either a Model parameter, or an EditContext parameter, please provide one of these

$
0
0

I'm receiving this error: "EditForm requires either a Model parameter, or an EditContext parameter, please provide one of these."

But I'm providing an (initialized) Model parameter to the EditForm like this:

Login.razor:<div class="page"\><MudContainer Class="login-page-container" MaxWidth="MaxWidth.Medium"\><div><MudText Typo="Typo.h3" GutterBottom Align="Align.Center" Class="font-bold">Welcome     Back!</MudText><EditForm Model="@Input" method="post" OnSubmit="LoginUser" FormName="login"><DataAnnotationsValidator /><MudTextField Label="Email or Username" Placeholder="Email or Username"                              @bind-Value="Input.EmailOrUsername" For="@(()=>                                                    Input.EmailOrUsername)"                              Variant="Variant.Outlined" Immediate="true" /><MudTextField Label="Password" Placeholder="Password"                              @bind-Value="Input.Password" For="@(()=> Input.Password)"                              InputType="InputType.Password" Variant="Variant.Outlined" Immediate="true" /><MudCheckBox Label="Remember Me"                             @bind-Value="Input.RememberMe" For="@(()=> Input.RememberMe)" /><MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary" FullWidth="true">LOG IN</MudButton><MudLink Typo="Typo.overline" href="#" Class="sign-up">DON'T HAVE AN ACCOUNT? SIGN UP</MudLink></EditForm></div><MudLink Href="#" Underline="Underline.Always" Class="text-center font-bold">RESET PASSWORD</MudLink></MudContainer>Login.razor.cs:public sealed partial class Login{[CascadingParameter]private HttpContext? HttpContext { get; set; }[SupplyParameterFromQuery]private string? ReturnUrl { get; set; }[SupplyParameterFromForm]private InputModel Input { get; set; } = new();    protected override async Task OnInitializedAsync()    {        if (HttpContext != null && HttpMethods.IsGet(HttpContext.Request.Method))        {            await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);        }    }    public async Task LoginUser()    {        ...    }    private sealed class InputModel    {        public string EmailOrUsername { get; set; } = string.Empty;        public string Password { get; set; } = string.Empty;        public bool RememberMe { get; set; }    }}

I've tried interactive mode, but it doesn't work with HttpContext.

I want to mantain the autocomplete from the browser as well. But nothing seems to work properly.

Thanks!


Viewing all articles
Browse latest Browse all 4839

Trending Articles