MudBlazor MudForm POST on Enter
Asked Answered
U

2

10

I'm looking for a way to post a MudForm upon pressing Enter from any control inside the form, without checking each keyboardevent argument and filtering for Enter, and without binding the listener to each form control in every MudForm.

The goal is to post any MudForm across my project by pressing Enter as a default behavior.

Unmanly answered 15/2, 2022 at 13:11 Comment(1)
@User101 No, i ended up with submit buttons for my forms, i added the eventlistener only for the login form's password-input.Unmanly
C
0

You will need to use EditForm for this: https://mudblazor.com/components/form#editform-support

Catechin answered 18/5, 2023 at 15:37 Comment(0)
S
0

I am not sure what you want to achieve, but I give it a go with my thoughts.

MudTextField updates the bound value on Enter or when it loses focus, meaning you can initiate the posting process from the setter.

<MudTextField @bind-Value="Name" Label="Enter your name" />
public User user;

public string Name 
{ 
    get { return user.name; }
    set { user.name = value; DoPostInfo(); }
}

The downside is that you can't make DoPostInfo async without putting some extra work into it.

Scarron answered 27/5, 2023 at 22:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.