Skip to content

blazor form submit need click twice when correction data #19403

@lmomimi

Description

@lmomimi

Describe the bug

blazor form submit need click twice when correction data

To Reproduce

@page "/"
@using System.ComponentModel.DataAnnotations;
@using System;

<h1>Hello, world!</h1>

Welcome to your new app.


<EditForm Model="@_exampleModel" OnValidSubmit="HandleValidSubmit">
    <DataAnnotationsValidator />
    <ValidationSummary />

    <InputText id="name" @bind-Value="_exampleModel.Name" />

    <button type="submit" class="button">Submit</button>
</EditForm>

@code {
   

public class ExampleModel
{
    [Required]
    [StringLength(10, ErrorMessage = "Name is too long.")]
    public string Name { get; set; }
}

 private ExampleModel _exampleModel = new ExampleModel();

    private void HandleValidSubmit()
    {
        Console.WriteLine("OnValidSubmit");
    }
}

Further technical details

  • ASP.NET Core version 3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions