Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 88129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:30:40+00:00 2026-05-10T22:30:40+00:00

I’m working on an ASP.NET page, using VB.NET and I have this hierarchy: Page

  • 0

I’m working on an ASP.NET page, using VB.NET and I have this hierarchy:

Page A
  – Web User Control 1
    – Web User Control A
    – Web User Control B
    – Web User Control C

I need to raise an event from Web User Control B that Page A will receive (the event flow will be Web User Control B -> Web User Control 1 -> Page A).

My only approach so far has been this: 1) Add a custom event declaration to both Web User Control B and Web User Control 1 and simply RaiseEvent twice until it gets to Page A (this seems ugly and I don’t particularly like it).

My other idea was to create a custom Event class that inhertis from some magical base Event class and create an instance of it in both Web User Control B and Web User Control 1, but that is proving fruitless because I can’t find any event base classes (maybe b/c they’re aren’t any, since it appears to be a keyword, not a class name).

Any help would be appreciated! Thanks and happy coding!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:30:41+00:00Added an answer on May 10, 2026 at 10:30 pm

    You can use the BubbleEvent concept to do this. A BubbleEvent goes up the control hierarchy until someone handles it. The GridView and Repeater controls do this with their Row/ItemCommand events.

    You could implement it into WebUserControl1, turning it into a standard event for the page (like the GridView does):

    Class UserControl1 ' Parent    Protected Override Function OnBubbleEvent(sender as Object, e as EventArgs) as Boolean        Dim c as CommandEventArgs = TryCast(e, CommandEventArgs)        If c IsNot Nothing Then            RaiseEvent ItemEvent(sender, c)            Return True ' Cancel the bubbling, so it doesn't go up any further in the hierarchy        End If        Return False ' Couldn't handle, so let it bubble    End Function     Public Event ItemEvent as EventHandler(Of CommandEventArgs) End Class  Class UserControlB ' Child     Protected Sub OnClicked(e as EventArgs)         ' Raise a direct event for any handlers attached directly         RaiseEvent Clicked(Me, e)         ' And raise a bubble event for parent control         RaiseBubbleEvent(Me, New CommandEventArgs('Clicked', Nothing))     End Sub      Protected Sub OnMoved(e as EventArgs)         ' Raise a direct event for any handlers attached directly         RaiseEvent Moved(Me, e)         ' And raise a bubble event for parent control         RaiseBubbleEvent(Me, New CommandEventArgs('Moved', Nothing))     End Sub End Class  Class PageA     Sub UserControl1_ItemEvent(sender as Object, e as CommandEventArgs) Handles UserControl1.ItemEvent         Response.Write(sender.GetType().Name & ' was ' & e.CommandName)     End Sub End Class 

    Or, do it directly in the page. UserControlB (Child) is the same as above, and UserControl1 (Parent) doesn’t need to do anything special – OnBubbleEvent defaults to returning False, so the event bubbles up:

    Class PageA    Protected Override Function OnBubbleEvent(sender as Object, e as EventArgs) as Boolean        If sender Is UserControlB Then            Dim c as CommandEventArgs = TryCast(e, CommandEventArgs)            If c IsNot Nothing Then                Response.Write(sender.GetType().Name & ' was ' & c.CommandName)            Else                Response.Write(sender.GetType().Name & ' raised an event, with ' & e.GetType().Name & ' args)            End If            Return True ' Cancel the bubbling, so it doesn't go up any further in the hierarchy        End If        Return False ' Not handled    End Function End Class 

    If your initial event is from a server control (like a Button.Click), then it will have been coded to already raise the bubble event – so UserControlB (Child) doesn’t need to do anything to get that to the parent either. You just need to call RaiseBubbleEvent for any of your custom events, or if you want to transform the EventArgs in some way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.