Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Blazor exhibits inconsistent behavior when handling forms with multiple buttons. The following is an example form which contains 2 buttons. When a user clicks on a button the component should tell the user which button was clicked:
<form method="post" @onsubmit="Submit" @formname="MyUniqueFormName">
<AntiforgeryToken />
<button type="submit" class="btn btn-primary" name="Action" value="Action1">Action1</button>
<button type="submit" class="btn btn-primary" name="Action" value="Action2">Action2</button>
</form>
@if (!string.IsNullOrEmpty(_message))
{
@((MarkupString)_message)
}
@code {
[SupplyParameterFromForm] public string Action { get; set; }
private string _message;
private void Submit()
{
_message = $"<br /><p>";
_message += "Action: " + ((Action != null) ? Action : "NULL");
_message += "</p>";
}
}
Running this code using Static rendering works correctly - it displays an action of “Action1” or “Action2” depending on which button is clicked:
However, running this code with Interactive rendering, the action always returns NULL.
Expected Behavior
Regardless of the render mode being used, form handling should be consistent. In this example it should return the action related to the button clicked.
Steps To Reproduce
Sample component code is included in the issue report. The component would need to be instantiated using Interactive render mode to reproduce the problem reported.
Exceptions (if any)
No response
.NET Version
8.0.1
Anything else?
No response