event handling in asp.net

M

Mike Gaab

I am having two problems:

1. Determing the signature of event handlers for any control that raises
events. I have a handle on the arguments but the method name is not clear.

2. What is the relationship between event properties and public methods
listed in the VS class browser. An example will help describe this one.

For example, the DataGrid has a event property named EditCommand, what is
the signature of the event handler for the event?

The DataGrid also exposes a public method called OnEditCommand(...),
is this method associated to the EditCommand?

In the meantime, I'll create an example and maybe answer my question.

Mike
 
F

Flinky Wisty Pomm

The public methods associated with control events allow you to manually
raise the event. When you call that method and pass a
DataGridCommandEventArgs, the control will in turn call any event
handlers, passing itself and that same EventArgs instance. You might
want to do this from a custom control, for example - you could have a
custom control inside a datagrid and in the handler for its onclick
method, raise the onEditCommand event of the containing grid.

The signature for the event is void (object, DataGridCommandEventArgs)

There isn't always a quick and easy way of working put what the
signature of an event handler should be - I personally use Google, or a
FireFox bookmarklet.
 
M

Mike Gaab

Flinky Wisty Pomm said:
The public methods associated with control events allow you to manually
raise the event. When you call that method and pass a
DataGridCommandEventArgs, the control will in turn call any event
handlers, passing itself and that same EventArgs instance. You might
want to do this from a custom control, for example - you could have a
custom control inside a datagrid and in the handler for its onclick
method, raise the onEditCommand event of the containing grid.

The signature for the event is void (object, DataGridCommandEventArgs)

There isn't always a quick and easy way of working put what the
signature of an event handler should be - I personally use Google, or a
FireFox bookmarklet.

The methods that are associated with control events are protected, not
public. So if I subclass DataGrid I should have access to those methods but
I don't? I am from the Java world so this is not making sense that I can't
see the control event methods from the subclass. I probably have to
declare/define them in the subclass. Could easily be missing something but
can't see what that is right now. Hmmmm...

Mike
 
F

Flinky Wisty Pomm

Sorry, my bad they are protected, yes - you can't access them from the
subclass? That's odd. Ignore my ravings about handling them earlier. Up
all night.

You should be able to call them from a derived class, or override them
- if you override an event method, make sure that you call
base.OnWhateverEvent. Can you post some code?
 
M

Mike Gaab

Flinky Wisty Pomm said:
Sorry, my bad they are protected, yes - you can't access them from the
subclass? That's odd. Ignore my ravings about handling them earlier. Up
all night.

You should be able to call them from a derived class, or override them
- if you override an event method, make sure that you call
base.OnWhateverEvent. Can you post some code?

Hey - no problem.
No example code.

Get some sleep. :)

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top