Javatpoint Logo
Javatpoint Logo

ASP.NET Web Forms Events Handling

ASP.NET provides important feature event handling to Web Forms. It let us to implement event-based model for our application. As a simple example, we can add a button to an ASP.NET Web Forms page and then write an event handler for the button's click event. ASP.NET Web Forms allows events on both client and server sides.

In ASP.NET Web Forms pages, however, events associated with server controls originate on the client but are handled on the Web server by the ASP.NET.

ASP.NET Web Forms follow a standard .NET Framework pattern for event-handler methods. All events pass two arguments: an object representing the object that raised the event, and an event object containing any event-specific information.

Example: Creating Event Handler

Here, we are creating an event handler for click event. In this example, when user click on the button, an event fires and handler code executes at server side.

// EventHandling.aspx

Code Behind

// EventHandling.aspx.cs

Output:

ASP Web forms event 1




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA