Hi Lars!
CustomControl is basicaly Class and classes can have events. If you have
worked with properties in ASCX you know, that you have to publish properties
from your control and so is with events:
part of x.ASCX.vb file:
' Declare custom event
Public Event myButtonClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
' Handel event on ASCX
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Raise your event
RaiseEvent myButtonClick(Me, e)
End Sub
Then you have known issue by using this ascx on ASPX. Namely when you drag
ASCX control on your page Visual Studio .NET 2003 does not declare varibales,
so you have to do it by hand and then you can use your events:
part of code on x.ASPX.vb:
' First declare variable with the same name as ID of your web custom control
Protected WithEvents clickable1 As Clickable
' then you can use events
Private Sub clickable1_myButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles clickable1.myButtonClick
Response.Write("Yeah")
End Sub
That's all. If you think that code is not readable enough I can send you
sample project.
Dusan Zupancic
"Lars Netzel" wrote:
I have made a pretty small and simple webCustomerControl that basically just
renders some HTML tables... I want parts of this to be clickable to fire off
a "Click Event" that you can use as a developer, how do I do this?
best regards/
Lars Netzel