Inherited Control Does Not Handle All Events

Discussion in 'ASP .Net Building Controls' started by Jeff, Dec 4, 2006.

  1. Jeff

    Jeff Guest

    Hello everyone,

    I'm building a series of custom controls inherited from an ImageButton
    and certain events are never getting thrown, or at least their handlers
    in the code are never running. Init, Load, DataBinding, PreRender and
    Unload are all working fine. Click, Command and Dispose never get run.
    Does anyone have any idea why this might be happening?

    My basic hierarchy, should that be important, is as follows:

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Class BaseIconButton
    Inherits ImageButton

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Class DeleteButton
    Inherits BaseIconButton

    Public Class InsertButton
    Inherits BaseIconButton

    Public Class EditButton
    Inherits BaseIconButton

    Public Class UpdateButton
    Inherits BaseIconButton

    Public Class CancelButton
    Inherits BaseIconButton
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    It is the events for the second group of classes that I cannot capture.
    If I test a BaseIconButton, then everything works perfectly.

    Thanks
     
    Jeff, Dec 4, 2006
    #1
    1. Advertising

  2. Jeff

    GJH Guest

    Did by chance you add the click Events in the class and leave them blank?

    In your class file does something like this work?
    Protected Overrides Sub OnInit(ByVal e As System.EventArgs)

    Me.EnsureChildControls()

    End Sub

    Private Sub DeleteButton_Click(ByVal sender As Object, ByVal e As
    System.Web.UI.ImageClickEventArgs) Handles MyBase.Click

    Page.Response.Write("hi")

    End Sub





    "Jeff" <> wrote in message
    news:...
    > Hello everyone,
    >
    > I'm building a series of custom controls inherited from an ImageButton
    > and certain events are never getting thrown, or at least their handlers
    > in the code are never running. Init, Load, DataBinding, PreRender and
    > Unload are all working fine. Click, Command and Dispose never get run.
    > Does anyone have any idea why this might be happening?
    >
    > My basic hierarchy, should that be important, is as follows:
    >
    > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    > Public Class BaseIconButton
    > Inherits ImageButton
    >
    > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    > Public Class DeleteButton
    > Inherits BaseIconButton
    >
    > Public Class InsertButton
    > Inherits BaseIconButton
    >
    > Public Class EditButton
    > Inherits BaseIconButton
    >
    > Public Class UpdateButton
    > Inherits BaseIconButton
    >
    > Public Class CancelButton
    > Inherits BaseIconButton
    > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    > It is the events for the second group of classes that I cannot capture.
    > If I test a BaseIconButton, then everything works perfectly.
    >
    > Thanks
    >
     
    GJH, Dec 4, 2006
    #2
    1. Advertising

  3. Jeff

    Jeff Guest

    I did not define the events or their handlers.

    It almost seems like since the classes I am interested in are being
    inherited from a class that doesnt explicitly define these events, that
    they arent getting them. That doesnt really make sense to me though
    since everything should be inherited across every level. I have tried:

    Private Sub InsertButton_Click(ByVal sender As Object, ByVal e
    As System.Web.UI.ImageClickEventArgs) Handles MyBase.Click
    debugme() '<--- breakpoint here never hits
    End Sub

    with no luck. However, similar code in the BaseIconButton hits fine.
    Again, I want to say that it seems like the second generation inherited
    classes arent inheriting these events.

    GJH wrote:
    > Did by chance you add the click Events in the class and leave them blank?
    >
    > In your class file does something like this work?
    > Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
    >
    > Me.EnsureChildControls()
    >
    > End Sub
    >
    > Private Sub DeleteButton_Click(ByVal sender As Object, ByVal e As
    > System.Web.UI.ImageClickEventArgs) Handles MyBase.Click
    >
    > Page.Response.Write("hi")
    >
    > End Sub
    >
    >
    >
    >
    >
    > "Jeff" <> wrote in message
    > news:...
    > > Hello everyone,
    > >
    > > I'm building a series of custom controls inherited from an ImageButton
    > > and certain events are never getting thrown, or at least their handlers
    > > in the code are never running. Init, Load, DataBinding, PreRender and
    > > Unload are all working fine. Click, Command and Dispose never get run.
    > > Does anyone have any idea why this might be happening?
    > >
    > > My basic hierarchy, should that be important, is as follows:
    > >
    > > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    > > Public Class BaseIconButton
    > > Inherits ImageButton
    > >
    > > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    > > Public Class DeleteButton
    > > Inherits BaseIconButton
    > >
    > > Public Class InsertButton
    > > Inherits BaseIconButton
    > >
    > > Public Class EditButton
    > > Inherits BaseIconButton
    > >
    > > Public Class UpdateButton
    > > Inherits BaseIconButton
    > >
    > > Public Class CancelButton
    > > Inherits BaseIconButton
    > > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    > > It is the events for the second group of classes that I cannot capture.
    > > If I test a BaseIconButton, then everything works perfectly.
    > >
    > > Thanks
    > >
     
    Jeff, Dec 4, 2006
    #3
    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. AC [MVP MCMS]

    Inherited page events not being hit

    AC [MVP MCMS], Jun 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    617
    Karl Seguin
    Jun 2, 2005
  2. konox
    Replies:
    0
    Views:
    415
    konox
    Oct 31, 2005
  3. Leon
    Replies:
    2
    Views:
    564
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    422
    Chris
    Aug 30, 2005
  5. 7stud --
    Replies:
    11
    Views:
    467
    7stud --
    Nov 9, 2007
Loading...

Share This Page