dotnet / dotnet/core

Issues for Razor tag form with action and @onsubmit together

Open
#5,540 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PowerShell
Stars
22k
Forks
4.9k
Avg merge
5d 5h
Merged PRs (30d)
29

Description

# Issue Title
Issues for Razor tag form with action and @onsubmit together

# General
With the classic form tag like the follow:
```

Click Me!/button>

```

when the button is clicked the event (or in this case the lambda event) referenced by the @onsubmit server attribute is correctly intercepted and executed but this situation prevents the form "action" to be executed!!!!

Why this?
Even with:
@onsubmit:preventDefault="true/false"
@onsubmit:stopPropagation="true/false"
in every possible combinations the form action won't be executed.

Obviously I know the alternative of
- using a Controller and avoid the use of @onsubmit attribute
- emulate the form action by something like the javascript call with
```
window.location=
```
- the razor tag EditForm!!!

But the issues remains:
how is possible for example launch the form with an action external of current application site?

On the other hand I suppose not even EditForm has something like "action" attribute for call some "external" controller/webservices or something similar and send some data after some internal controls and elaborations.

I repeat myself:
I know is possible to do this thing by some Controller
with Redirect / Challenge instructions

But the question is why and how submit the form in the "action" attribute sites after the execution of the event referenced by the @onsubmit server attribute?

On the other hand if the @onsubmit attribute is removed, the form will take the data and go to the site referenced by the "action" attribute correctly.

There is something that I didn't understand about some other server attributes (@) in the form tag or there are some already existent razor netcore tag that solve the problem and has the behaviour requested by this current issue?

If this forum or section is wrong, somebody could redirect in the right location issues, please?

Thanks and I hope and wait for some fast explanation and / or some solutions.

Thanks and best regards.

Bye.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.