dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.37k stars 9.99k forks source link

EditForm that is placed on an interactive server page does not trigger submit handler. #56634

Closed htmlsplash closed 3 months ago

htmlsplash commented 3 months ago

Is there an existing issue for this?

Describe the bug

Context: Blazor Web app project, static SSR as default.

Problem described is on the page (with Interactive Server render mode) that contains EditForm that captures user's input but OnSubmit doesn't fire it's corresponding event handler. I can see in the browser the web-socket sending message, but nothing happens, no event handler is triggered.

Here's the Code:

@page "/clientsearch2" @layout PimarcLayout @rendermode InteractiveServer

<EditForm Model="ClientCriteria" OnSubmit="OnClientSearch">

Content of Edit From:

` <InputText @bind-Value="ClientCriteria.ClientNumber" class="form-control" />

            <button class="btn btn-secondary" type="reset">Reset</button>`

`Received Client #: @ClientCriteria.ClientNumber

Submitted flag: @_submittedFlag

@code {

public ClientSearchCriteria2 ClientCriteria { get; set; } = new();
private string _submittedFlag;

public void OnClientSearch()
{
    _clientCriteria = ClientCriteria;
}

private ClientSearchCriteria2 _clientCriteria = new();

protected override void OnInitialized()
{
}

}`

Expected Behavior

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

htmlsplash commented 3 months ago

I figured out the problem, it works.