User Control Event Not Firing

Discussion in 'ASP .Net' started by Landley, Sep 29, 2005.

  1. Landley

    Landley Guest

    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
     
    Landley, Sep 29, 2005
    #1
    1. Advertising

  2. Landley

    Landley Guest

    Ignore this posting. I need to learn how to spell!

    L.

    "Landley" <> wrote in message
    news:%...
    > 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
    >
    >
     
    Landley, Sep 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Thomas
    Replies:
    3
    Views:
    835
  2. vatech1993
    Replies:
    4
    Views:
    5,718
    =?Utf-8?B?U8Opcmdpbw==?=
    Dec 11, 2004
  3. ~~~ .NET Ed ~~~
    Replies:
    3
    Views:
    15,175
    nizarbabu
    Sep 8, 2008
  4. Don
    Replies:
    3
    Views:
    5,511
    Karl Seguin
    Mar 11, 2005
  5. EvelynAnd Ethan
    Replies:
    4
    Views:
    1,003
    =?Utf-8?B?Sko=?=
    Jan 9, 2006
Loading...

Share This Page