1
Answer

How to use html button in asp.net backend coding

Madhu Patel

Madhu Patel

1y
47
1

<input type="button" value="Submit" />

 

How to use asp.net backend code In above html button tag without using javascript ?

Answers (1)
0
Deepak Tewatia

Deepak Tewatia

13 15.6k 21.8k 1y

Certainly! In ASP.NET, you can use an HTML button in the frontend and handle its click event in the backend without using JavaScript. Here's how you can achieve this:

In your ASP.NET web form, you can add an HTML button like this:


<input type="button" value="Submit" runat="server" onclick="SubmitButton_Click" />

By adding the attribute `runat="server"`, you can access this button directly in the code-behind file. The `onclick` attribute specifies the name of the server-side method that will handle the button click event.

In your code-behind file (e.g., page.aspx.cs), you can define the corresponding C# method for the button click:


protected void SubmitButton_Click(object sender, EventArgs e)
{
    // Handle the button click event here
    // You can write your backend code to process the button click
}

When the button is clicked in the frontend, the `SubmitButton_Click` method in the code-behind file will be executed, allowing you to handle the button click event without using JavaScript.

This approach allows you to handle button clicks in the ASP.NET backend without relying on client-side JavaScript code. If you have further questions or need additional examples, feel free to ask!