Why is it that in .aspx pages all events are preceded with "On
" e.g. "OnClick
", "OnCommand
" and in the code-behind file they are referred "Click
", "Command
"? Just Naming Convention or is there some logical explanation?
The names of the events themselves are Click, Change, etc... The internal methods to fire those events from code are prefixed with "On" as a naming convention. In ASP.NET markup, you use the attribute OnClick but what you're really doing is wiring a method to the "Click" event. Therefore, the method autogenerated for you by VS is ButtonName_Click. This method is internally passed as a delegate to the event itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With