Inherited Control Does Not Handle All Events

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Inherited Control Does Not Handle All Events

    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 Guest

  2. Similar Questions and Discussions

    1. resize control inherited from System.Web.UI.Control in design mode
      How I can resize control inherited from System.Web.UI.Control in design mode. Thanks a lot.
    2. How to handle events of controls created at run time?
      Hi, My application has two methods which creates buttons at runtime. In one method I am able to handle the events of the buttons created at run...
    3. How to add multiple buttons to a datagrid row... and handle their events
      I have a DataTable that I'm currently displaying in a DataGrid... but I have the case where I need to use multiple buttons/linkButtons in each row of...
    4. Can we handle events for user controls
      Can we handle events for user controls? If so how? Suppose we r creating a user control using a label can we handle a event for the user control...
    5. Question: Handle Events From Web User Controls
      I was reading an article that talked about using the OnBubbleEvent overrides function to handle events from a web user control...
  3. #2

    Default Re: Inherited Control Does Not Handle All Events

    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" <jeffmagill@gmail.com> wrote in message
    news:1165257116.912044.4970@73g2000cwn.googlegroup s.com...
    > 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 Guest

  4. #3

    Default Re: Inherited Control Does Not Handle All Events

    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" <jeffmagill@gmail.com> wrote in message
    > news:1165257116.912044.4970@73g2000cwn.googlegroup s.com...
    > > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139