Problem with sub???

G

Guest

Can someone tell me why I get this error???

And how do I fix it??

Thanks

Compiler Error Message: BC30408: Method 'Public Sub UploadData()' does not
have the same signature as delegate 'Delegate Sub EventHandler(sender As
Object, e As System.EventArgs)'.

Source Error:
Line 221:<TD width="10"></TD>
Line 222:<TD width="180">
Line 223:<asp:button id="Upload" OnClick="UploadData" runat="server"
Text="Upload"></asp:button></TD>
Line 224:<TD></TD>
Line 225:</TR>
 
K

Kevin Spencer

Hi Tim,

First, some background:

ASP.Net Controls have server-side event handlers. An event handler is a
method that handles the type of event raised by the particular class. A
delegate is a kind of "blueprint" if you will, for an event handler specific
to a certain type of event. It defines the signature of the event-handler
method. The signature is the definition of the method name and the
parameters it takes. A delegate Sub has a signature but no code. Example:

Delegate Sub EventHandler(sender As Object, e As System.EventArgs)

Note that it looks like a regular method (Sub or Function), but has no code
associated with it. It is, again, like a "blueprint."

There are different Event types, and different classes raise different
events. The EventArgs class is the base type for all EventArgs classes. An
EventArgs class generally (but not always) contains information about the
event that was fired. That information is supplied by the class that raised
the Event.

So, when you write an Event Handler for a specific Control (which is a
class), its signature must match the signature of the Event Delegate defined
for that type of Event.

Now, in this specific case, you have defined an "OnClick" event handler
somewhere in your code, and the signature for it does not match the
signature of the Delegate for that Event. And of course, by now it should be
obvious what the solution is: Give your Event Handler Sub the same signature
as the Delegate.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 
A

Angrez Singh

Hi,
Apart fromt "Kevin Spencer" reply you need to tell which Button's click
event it is implementing.
something like:
public sub eventHander(object sender, EventArgs args) Implements
Button.Click

HTH
Regards,
Angrez
 

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

Top