User Control Event Not Firing

L

Landley

Hi All,

I am trying to raise a custom event from a user control. I have supplied my
code below. It calls OnSave method that attempts to raise the save event,
but it never gets to the handler in the default.aspx.vb file.

[registration.ascx]
Public Event Save(ByVal sender As Object, ByVal e As
RegistrationFormEventArgs)

Protected Overridable Sub OnSave(ByVal sender As Object, ByVal e As
RegistrationFormEventArgs)
RaiseEvent Save(sender, e)
End Sub

[default.aspx]
<%@ Register TagPrefix="cs" TagName="RegistratonForm"
src="./controls/RegistrationFormTable.ascx" %>
...
<cs:RegistratonForm ID="RegistratonForm" Runat="server"
Visible="False"></cs:RegistratonForm>
...

[registration.ascx.vb]
Dim e As RegistrationFormEventArgs

Try
e = New RegistrationFormEventArgs([My Parameters Go Here])
OnSave(Me, e)

If e.Saved Then
ClearForm()
Else
MessageLabel.Text = "Save Failed. " & e.ErrorMessage
End If

Catch ex As Exception
RaiseException(ex)

Finally
e = Nothing

End Try

[default.aspx.vb]
Private Sub RegistrationForm_Save(ByVal sender As Object, ByVal e As
RegistrationFormEventArgs) Handles RegistrationForm.Save
Try
..

Catch ex As Exception
RaiseException(ex)

e.Saved = False
e.ErrorMessage = ex.Message

End Try

End Sub


Any ideas?

Landers
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top