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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manikandan MurugesanRank #300 · 8.4K reputationPosted Jan 28, 2024, 10:58 PM EST
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#Jithu ThomasRank #437 · 5.7K reputationPosted Jan 29, 2024, 12:46 AM EST
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.