Bubbling Event ---- Problem!!!!

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

  1. #1

    Default Re: Bubbling Event ---- Problem!!!!

    Mackarand,

    Is the user control being reloaded on post back?

    I'm doing exactly what you describe on my own web site. When I decided to go
    this route the first thing I found was that I needed to reload the control
    into its placeholder for for the event to fire.

    I hope this helps.

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "Makarand" <mkeer@celpro.com> wrote in message
    news:053601c34dda$1d4c6120$a601280a@phx.gbl...
    > Hi
    > I am having ASP.NET user control in which I have ASP.NET
    > DataGrid Control. To this dataGrid Control I am
    > dynamically adding controls using 'Dynamic addition of
    > ItemTemplate'. Now I want to send the event that is raised
    > by the control which is added dynamically to the consumer
    > of my 'ASP.NET user control'. For that I intend to use
    > Event Bubbling. But It is not working in my case.
    >
    > I am using RaiseBubbleEvent method in ItemTemplate class
    > to send the event to parent control and OnBubbleEvent
    > method to catch the Events in my UserControl, but I dopn't
    > get the events in UserControl
    >
    > Can any one help me?
    >
    > Thanx in advanced
    > Makarand

    S. Justin Gengo Guest

  2. Similar Questions and Discussions

    1. Event Bubbling Custom Object not inheriting from control
      One of the new things flash flex and xaml have are ways which the event easily bubbles up to a parent that knows how to handle the event. Similar...
    2. Event Bubbling From The HeaderTemplate
      I have three LinkButtons in the HeaderTemplate of my DataList (I use them to let the user determine what to sort the list by). I am assuming that...
    3. Event Bubbling
      Dear Folks, I have some issue with bubbling the event above two levels in the hierarch I have a web custom control 'B' . 'B' consists of a button...
    4. Bubbling Event in Composite controls
      Hi Everyone, I am building a composite server control. I have defined an event for my child control with Custom Event Arguments. I am using the...
    5. Event Bubbling from a template
      Hi, I have a template in a DataList. The template also contains a DataList. I'd like to bubble the OnItemCommand event from the template's...
  3. #2

    Default Re: Bubbling Event ---- Problem!!!!

    Hello Justin

    I could not understand exactly what you are saying.
    Have you solved this problem in your project? if yes could
    you please give me the code files in which you have used
    bubbling of events from Child controls.

    Thanx in advanced.
    BTW I am Makarand and not Mackarand :)

    Regards
    Makarand
    >-----Original Message-----
    >Mackarand,
    >
    >Is the user control being reloaded on post back?
    >
    >I'm doing exactly what you describe on my own web site.
    When I decided to go
    >this route the first thing I found was that I needed to
    reload the control
    >into its placeholder for for the event to fire.
    >
    >I hope this helps.
    >
    >--
    >S. Justin Gengo, MCP
    >Web Developer
    >
    >Free code library at:
    >[url]www.aboutfortunate.com[/url]
    >
    >"Out of chaos comes order."
    > Nietzche
    >"Makarand" <mkeer@celpro.com> wrote in message
    >news:053601c34dda$1d4c6120$a601280a@phx.gbl...
    >> Hi
    >> I am having ASP.NET user control in which I have ASP.NET
    >> DataGrid Control. To this dataGrid Control I am
    >> dynamically adding controls using 'Dynamic addition of
    >> ItemTemplate'. Now I want to send the event that is
    raised
    >> by the control which is added dynamically to the
    consumer
    >> of my 'ASP.NET user control'. For that I intend to use
    >> Event Bubbling. But It is not working in my case.
    >>
    >> I am using RaiseBubbleEvent method in ItemTemplate class
    >> to send the event to parent control and OnBubbleEvent
    >> method to catch the Events in my UserControl, but I
    dopn't
    >> get the events in UserControl
    >>
    >> Can any one help me?
    >>
    >> Thanx in advanced
    >> Makarand
    >
    >
    >.
    >
    Makarand Guest

  4. #3

    Default Re: Bubbling Event ---- Problem!!!!

    Makarand,

    Sorry about the typo in your name!

    Yes, I've solved this problem.

    Here is some sample code:

    'In the page load event I use the following code to determine if a control
    should be reloaded:

    If Page.IsPostBack Then
    '---Post back only

    If CType(ViewState("ReloadControl"), String) > "" Then

    Dim ControlToLoad As String = ViewState("ReloadControl").ToString

    plchldrContent.Controls.Add(LoadControl(ControlToL oad))

    End If

    End If



    '---The following code is used to get the event bubbled up from a control to
    the default page. (The events I'm showing here all load new controls onto
    the page.)

    Protected Overrides Function OnBubbleEvent(ByVal source As Object, ByVal
    args As System.EventArgs) As Boolean

    Try

    Select Case (source.GetType.ToString)

    Case "System.Web.UI.WebControls.Button"

    Dim mobjButton As Button

    mobjButton = CType(source, System.Web.UI.WebControls.Button)

    Select Case mobjButton.ID

    Case "BiographyButton"

    Call MenuButtonClicked("pages/Biography.ascx", False)

    End Select

    Case "System.Web.UI.WebControls.LinkButton"

    Dim mobjButton As LinkButton

    mobjButton = CType(source, System.Web.UI.WebControls.LinkButton)

    Select Case mobjButton.ID

    Case "FavoritesLinkButton"

    Call MenuButtonClicked("pages/favorites.ascx", True)

    End Select

    End Select

    Catch ex As Exception

    Call ProcessError("There was a menu button error:", ex)

    End Try

    End Function



    '---When a button that loads a different control into the page is clicked
    this function loads the control
    Private Sub MenuButtonClicked(ByVal ControlToLoad As String, ByVal
    ReloadControl As Boolean)

    Try

    If Not CType(ViewState("ReloadControl"), String) = ControlToLoad Then

    plchldrContent.Controls.Clear()

    plchldrContent.Controls.Add(LoadControl(ControlToL oad))

    Call SetControlReload(ControlToLoad, ReloadControl)

    End If

    Catch ex As Exception

    Throw ExceptionCaught

    End Try

    End Sub



    '---If the control has objects with events that will be bubbled up to the
    default page it needs to be reloaded.

    Private Sub SetControlReload(ByVal controlToLoad As String, ByVal
    reloadControl As Boolean)

    Try

    If reloadControl Then

    ViewState("ReloadControl") = controlToLoad.ToString

    Else

    ViewState("ReloadControl") = Nothing

    End If

    Catch ex As Exception

    Throw ex

    End Try

    End Sub


    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "Makarand" <mkeer@celpro.com> wrote in message
    news:033701c34f3d$f63b0bd0$a501280a@phx.gbl...
    > Hello Justin
    >
    > I could not understand exactly what you are saying.
    > Have you solved this problem in your project? if yes could
    > you please give me the code files in which you have used
    > bubbling of events from Child controls.
    >
    > Thanx in advanced.
    > BTW I am Makarand and not Mackarand :)
    >
    > Regards
    > Makarand
    >
    > >-----Original Message-----
    > >Mackarand,
    > >
    > >Is the user control being reloaded on post back?
    > >
    > >I'm doing exactly what you describe on my own web site.
    > When I decided to go
    > >this route the first thing I found was that I needed to
    > reload the control
    > >into its placeholder for for the event to fire.
    > >
    > >I hope this helps.
    > >
    > >--
    > >S. Justin Gengo, MCP
    > >Web Developer
    > >
    > >Free code library at:
    > >[url]www.aboutfortunate.com[/url]
    > >
    > >"Out of chaos comes order."
    > > Nietzche
    > >"Makarand" <mkeer@celpro.com> wrote in message
    > >news:053601c34dda$1d4c6120$a601280a@phx.gbl...
    > >> Hi
    > >> I am having ASP.NET user control in which I have ASP.NET
    > >> DataGrid Control. To this dataGrid Control I am
    > >> dynamically adding controls using 'Dynamic addition of
    > >> ItemTemplate'. Now I want to send the event that is
    > raised
    > >> by the control which is added dynamically to the
    > consumer
    > >> of my 'ASP.NET user control'. For that I intend to use
    > >> Event Bubbling. But It is not working in my case.
    > >>
    > >> I am using RaiseBubbleEvent method in ItemTemplate class
    > >> to send the event to parent control and OnBubbleEvent
    > >> method to catch the Events in my UserControl, but I
    > dopn't
    > >> get the events in UserControl
    > >>
    > >> Can any one help me?
    > >>
    > >> Thanx in advanced
    > >> Makarand
    > >
    > >
    > >.
    > >

    S. Justin Gengo Guest

  5. #4

    Default Re: Bubbling Event ---- Problem!!!!

    Thanx Friend.
    >-----Original Message-----
    >Makarand,
    >
    >Sorry about the typo in your name!
    >
    >Yes, I've solved this problem.
    >
    >Here is some sample code:
    >
    >'In the page load event I use the following code to
    determine if a control
    >should be reloaded:
    >
    >If Page.IsPostBack Then
    > '---Post back only
    >
    > If CType(ViewState("ReloadControl"), String) > "" Then
    >
    > Dim ControlToLoad As String = ViewState
    ("ReloadControl").ToString
    >
    > plchldrContent.Controls.Add(LoadControl
    (ControlToLoad))
    >
    > End If
    >
    >End If
    >
    >
    >
    >'---The following code is used to get the event bubbled
    up from a control to
    >the default page. (The events I'm showing here all load
    new controls onto
    >the page.)
    >
    >Protected Overrides Function OnBubbleEvent(ByVal source
    As Object, ByVal
    >args As System.EventArgs) As Boolean
    >
    >Try
    >
    > Select Case (source.GetType.ToString)
    >
    > Case "System.Web.UI.WebControls.Button"
    >
    > Dim mobjButton As Button
    >
    > mobjButton = CType(source,
    System.Web.UI.WebControls.Button)
    >
    > Select Case mobjButton.ID
    >
    > Case "BiographyButton"
    >
    > Call MenuButtonClicked
    ("pages/Biography.ascx", False)
    >
    > End Select
    >
    > Case "System.Web.UI.WebControls.LinkButton"
    >
    > Dim mobjButton As LinkButton
    >
    > mobjButton = CType(source,
    System.Web.UI.WebControls.LinkButton)
    >
    > Select Case mobjButton.ID
    >
    > Case "FavoritesLinkButton"
    >
    > Call MenuButtonClicked
    ("pages/favorites.ascx", True)
    >
    > End Select
    >
    > End Select
    >
    >Catch ex As Exception
    >
    > Call ProcessError("There was a menu button error:",
    ex)
    >
    >End Try
    >
    >End Function
    >
    >
    >
    >'---When a button that loads a different control into the
    page is clicked
    >this function loads the control
    >Private Sub MenuButtonClicked(ByVal ControlToLoad As
    String, ByVal
    >ReloadControl As Boolean)
    >
    >Try
    >
    > If Not CType(ViewState("ReloadControl"), String) =
    ControlToLoad Then
    >
    > plchldrContent.Controls.Clear()
    >
    > plchldrContent.Controls.Add(LoadControl
    (ControlToLoad))
    >
    > Call SetControlReload(ControlToLoad,
    ReloadControl)
    >
    > End If
    >
    >Catch ex As Exception
    >
    > Throw ExceptionCaught
    >
    >End Try
    >
    >End Sub
    >
    >
    >
    >'---If the control has objects with events that will be
    bubbled up to the
    >default page it needs to be reloaded.
    >
    >Private Sub SetControlReload(ByVal controlToLoad As
    String, ByVal
    >reloadControl As Boolean)
    >
    >Try
    >
    > If reloadControl Then
    >
    > ViewState("ReloadControl") =
    controlToLoad.ToString
    >
    > Else
    >
    > ViewState("ReloadControl") = Nothing
    >
    > End If
    >
    >Catch ex As Exception
    >
    > Throw ex
    >
    >End Try
    >
    >End Sub
    >
    >
    >--
    >S. Justin Gengo, MCP
    >Web Developer
    >
    >Free code library at:
    >[url]www.aboutfortunate.com[/url]
    >
    >"Out of chaos comes order."
    > Nietzche
    >"Makarand" <mkeer@celpro.com> wrote in message
    >news:033701c34f3d$f63b0bd0$a501280a@phx.gbl...
    >> Hello Justin
    >>
    >> I could not understand exactly what you are saying.
    >> Have you solved this problem in your project? if yes
    could
    >> you please give me the code files in which you have used
    >> bubbling of events from Child controls.
    >>
    >> Thanx in advanced.
    >> BTW I am Makarand and not Mackarand :)
    >>
    >> Regards
    >> Makarand
    >>
    >> >-----Original Message-----
    >> >Mackarand,
    >> >
    >> >Is the user control being reloaded on post back?
    >> >
    >> >I'm doing exactly what you describe on my own web site.
    >> When I decided to go
    >> >this route the first thing I found was that I needed to
    >> reload the control
    >> >into its placeholder for for the event to fire.
    >> >
    >> >I hope this helps.
    >> >
    >> >--
    >> >S. Justin Gengo, MCP
    >> >Web Developer
    >> >
    >> >Free code library at:
    >> >[url]www.aboutfortunate.com[/url]
    >> >
    >> >"Out of chaos comes order."
    >> > Nietzche
    >> >"Makarand" <mkeer@celpro.com> wrote in message
    >> >news:053601c34dda$1d4c6120$a601280a@phx.gbl...
    >> >> Hi
    >> >> I am having ASP.NET user control in which I have
    ASP.NET
    >> >> DataGrid Control. To this dataGrid Control I am
    >> >> dynamically adding controls using 'Dynamic addition
    of
    >> >> ItemTemplate'. Now I want to send the event that is
    >> raised
    >> >> by the control which is added dynamically to the
    >> consumer
    >> >> of my 'ASP.NET user control'. For that I intend to
    use
    >> >> Event Bubbling. But It is not working in my case.
    >> >>
    >> >> I am using RaiseBubbleEvent method in ItemTemplate
    class
    >> >> to send the event to parent control and OnBubbleEvent
    >> >> method to catch the Events in my UserControl, but I
    >> dopn't
    >> >> get the events in UserControl
    >> >>
    >> >> Can any one help me?
    >> >>
    >> >> Thanx in advanced
    >> >> Makarand
    >> >
    >> >
    >> >.
    >> >
    >
    >
    >.
    >
    Makarand 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