D
Don Q.
Hi,
I'm writing a class in VB that will (once I get it working) be rolled
up into a DLL for use in all our web applications. However I'm
running into problems with button events not firing.
Essentially, my (trimmed-down) code contains this:
Public Class ModalDialog
Protected WithEvents btnYes As New Button
Public Event ButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
Private Sub btnClick(ByVal sender As Object, ByVal e As
System.EventArgs)
RaiseEvent ButtonClick(sender, e)
End Sub
Public Sub SomeSubThatIKnowIsFiring()
AddHandler btnYes.Click, AddressOf btnClick
End Sub
End Class
Then, within the actual page code-behind, I have the following:
Partial Public Class _Default
Inherits System.Web.UI.Page
Dim MD As New ModalDialog
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
AddHandler MD.ButtonClick, AddressOf GetButtonClick
MyBase.OnInit(e)
End Sub
Protected Sub GetButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim btn As Button = DirectCast(sender, Button)
Msg.InnerHtml = btn.CommandName
End Sub
End Class
In the course of my playing around, I've found that although
ModalDialog.SomeSubThatIKnowIsFiring does indeed fire (as the name
implies), the btnClick sub (which should be raising the event) never
actually executes when I click the button.
I know this code (or its equivalent) should work in Windows
development, but this is my first foray into trying to handle custom
events within a web application. Could somebody point out what I'm
doing wrong, or provide a link to a good guide to handling custom
events, and persisting them upward from within a class up to the page
level?
Regards,
Don Q.
I'm writing a class in VB that will (once I get it working) be rolled
up into a DLL for use in all our web applications. However I'm
running into problems with button events not firing.
Essentially, my (trimmed-down) code contains this:
Public Class ModalDialog
Protected WithEvents btnYes As New Button
Public Event ButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
Private Sub btnClick(ByVal sender As Object, ByVal e As
System.EventArgs)
RaiseEvent ButtonClick(sender, e)
End Sub
Public Sub SomeSubThatIKnowIsFiring()
AddHandler btnYes.Click, AddressOf btnClick
End Sub
End Class
Then, within the actual page code-behind, I have the following:
Partial Public Class _Default
Inherits System.Web.UI.Page
Dim MD As New ModalDialog
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
AddHandler MD.ButtonClick, AddressOf GetButtonClick
MyBase.OnInit(e)
End Sub
Protected Sub GetButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim btn As Button = DirectCast(sender, Button)
Msg.InnerHtml = btn.CommandName
End Sub
End Class
In the course of my playing around, I've found that although
ModalDialog.SomeSubThatIKnowIsFiring does indeed fire (as the name
implies), the btnClick sub (which should be raising the event) never
actually executes when I click the button.
I know this code (or its equivalent) should work in Windows
development, but this is my first foray into trying to handle custom
events within a web application. Could somebody point out what I'm
doing wrong, or provide a link to a good guide to handling custom
events, and persisting them upward from within a class up to the page
level?
Regards,
Don Q.