how to use 'onclick' from aspx file with asp.net control?

B

Bob

Hi,

In code - behind, i wrote this code:

Sub serverklik()
Response.Write("serverklik")
End Sub

In aspx file, i defined this:
<asp:Button ID="Button3" runat="server" Text="Button" OnClick="serverklik"
/>

I get the error:
Method 'Public Sub serverklik()' does not have the same signature as
delegate 'Delegate Sub EventHandler(sender As Object, e As
System.EventArgs)'.


I know that i can do this in code-behind: (this works)
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button3.Click
Response.Write("serverklik")
End Sub


but my question is:
it must be possible to use the OnClick event in the aspx file that refers to
a procedure in code-behind.
How?

Thanks
Bob
 
G

Guest

It *is* possible. It just needs to have the correct signature for an
eventhandler, which is exactly what the exception message said. e.g.,

Protected Sub serverklik(ByVal sender As Object, ByVal e As
System.EventArgs)

Peter
 
B

Bob

Thanks

Peter Bromberg said:
It *is* possible. It just needs to have the correct signature for an
eventhandler, which is exactly what the exception message said. e.g.,

Protected Sub serverklik(ByVal sender As Object, ByVal e As
System.EventArgs)

Peter
 

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