ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,162 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am using asp.net core
there is a list page
and a add new button
and a edit.cshtml page
how to click the new button
to get the data of edit page
show it in list page
as
modal
and then when I click the submit button
it will not post to the edit page
but ajax to it?
If you want to prevent the default post method for the form's submit button, I suggest you could consider using the event.preventDefault()
method.
More details, you could refer to below codes:
<form id="user-form" method="post">
First name: <input type="text" name="first_name" id="first_name"><br/>
Last name: <input type="text" name="last_name" id="last_name"><br/>
Phone number: <input type="text" name="phone_number" id="phone_number"><br/>
<input type="submit" id="submit-btn">
</form>
JS:
document.getElementById("submit-btn").addEventListener("click", function(event){
event.preventDefault()
});