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

  • Thread starter Thread starter Bob
  • Start date Start date
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
 
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
 
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
 
Back
Top