Event Handling OOP

Asp.Net Events

In Asp.Net and similar visual programming languages, operations are performed using events and methods (subprograms - procedures) that will run when these events occur.

A user can perform an event or create an object. For example, clicking a button or typing in a text box are examples for event. Likewise, it is an event that a timer starts each round.

The application is created by writing methods for the desired events.

In Asp.NET every control (object) has a default event. For example, the default event of the button control is Click event. If we double-click the button we placed on the page, the Visual Studio program will perform two actions on our behalf.

  1. It specifies the method that will be called when this button is clicked, by adding the OnClick="Button1_Click" parameter to the code of the button. Since the name of the button is Button1 here, the name of the control and the name of the event are combined and the name to be given to the method (subroutine) is automatically created.
  2. It creates the relevant method in the code page and the cursor moves inside that method so that we can add the lines of code.

Default Events of Controls

The default events for commonly used controls are listed below. After adding these controls to our page, when we double-click on them, the method for the relevant event will be created automatically.

Page: Load - The event that the page was created on the server

Button: Click - Click event by the left mouse button

Calendar: SelectionChanged - Triggered when the selected date is changed

CheckBox: CheckedChanged - Triggered when checked changed

CheckBoxList: SelectedIndexChanged - Triggered when the selected item is changed

DropDownList: SelectedIndexChanged - Triggered when the selected item is changed

LinkButton: Click - Triggered when the left button of mouse clicked

ListBox: SelectedIndexChanged - Triggered when the selected item is changed

RadioButton: CheckedChanged - Triggered when checked changed

RadioButtonList: SelectedIndexChanged - Triggered when the selected item is changed

TextBox: TextChanged - Triggered when the text changed in the textbox

Apart from these, methods can be written for different events of a control. For this, by clicking the lightning bolt icon at the top of the Properties panel while the relevant control is selected, the name of the method to be created is written in front of the desired events. As soon as the name is typed and the Enter key is pressed, the program is created and displayed.

asp.net events, asp.net event tutorials, default events of controls asp.net c#, event schedules, event procedures, events, click, double click, keydown

EXERCISES

There are no examples related to this subject.



COMMENTS




Read 730 times.

Online Users: 921



event-handling-programming