0

I am a newbie to asp.net, can you please explain the line of code below?

this.lblDelete.Click += new System.EventHandler(this.lblDelete_Click);

I don't know much about events and delegates.

Matthias Güntert
  • 4,013
  • 6
  • 41
  • 89
Learner
  • 139
  • 1
  • 9

1 Answers1

0

Essentially the code attaches an event handler to an event so that it can be, well... handled.

A simple way to understand it would be.

This event:

this.lblDelete.Click

Has this event handler attached:

+= new System.EventHandler

Which calls this method:

lblDelete_Click
JasperMoneyshot
  • 357
  • 3
  • 15
  • But there is no method named 'lblDelete_Click' – Learner Jun 12 '18 at 16:29
  • Does the class that the codes in inherit from something else? If so the method maybe in the base class – JasperMoneyshot Jun 12 '18 at 16:32
  • The class is inheriting from another class, but that class(base) doesn't have any lblDelete_Click method. FYI.. this is available in child class only and it will be fired onclick of Delete LinkButton control. – Learner Jun 12 '18 at 18:31