How to use asp.net backend code In above html button tag without using javascript ?
How to use asp.net backend code In above html button tag without using javascript ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jithu ThomasPosted Jan 29, 2024, 5:46 AM
if you are using Asp.net Webforms :-
Code-Behind (aspx.cs file):
protected void SubmitButton_Click(object sender, EventArgs e)
{
// Handle the button click on the server-side
// Your server-side code goes here
}
if you are using Asp.net MVC View :-
@using (Html.BeginForm("Submit", "YourControllerName", FormMethod.Post))
{
}
Controller (YourControllerNameController.cs):
public class YourControllerNameController : Controller
{
// Other actions if any
[HttpPost]
public ActionResult Submit()
{
// Handle the form submission on the server-side
// Your server-side code goes here
return View(); // You can redirect to another view or return a response as needed
}
}
Please select which one is acceptable with your requirement.
Manikandan MurugesanPosted Jan 29, 2024, 3:58 AM
If you want to handle the click event of the HTML button in ASP.NET without using JavaScript, you can use the
runat="server"attribute in thetag and handle the button click event on the server side using C#