ASP.NET - Raise an event from a user control to the calling page

Raising an event from a user control back to the calling page is one of those ASP.NET patterns that every developer eventually needs, yet it’s rarely explained clearly. User controls are great for encapsulating UI and logic, but they often need to notify the parent page when something happens — a menu click, a selection, a change in state. This article shows the cleanest way to expose an event from a user control and handle it in the parent page using VB.NET. The pattern is simple, reliable

When a user control needs to communicate back to the page that hosts it, the most direct approach is to expose a public event. The parent page can then subscribe to that event during its initialization cycle. This keeps the control self-contained while still allowing the page to react to user actions.

In the example below, the user control defines an event named ProjectSummaryMenu_MenuSelectionMade. When the user clicks a menu item, the control raises the event and passes the RadMenuEventArgs back to the page. The parent page registers a handler in Init, ensuring the event wiring occurs early in the page lifecycle. Once the event fires, the page can inspect the selected menu item and take action — such as redirecting to another page.

This pattern avoids tight coupling, keeps the control reusable, and provides a clean, predictable way to push events upward in the control hierarchy.

This is the user control that contains a menu structure

Public Class ProjectSummaryMenu
    Inherits InheritedUserControl
 
    Public Event ProjectSummaryMenu_MenuSelectionMade As EventHandler(Of RadMenuEventArgs)
 
 
 
    Private Sub RadMenu1_ItemClick(sender As Object, e As RadMenuEventArgs) Handles RadMenu1.ItemClick
        Dim strError As String = ""
 
        Try
            'raise the event to the parent form
            RaiseEvent ProjectSummaryMenu_MenuSelectionMade(Me, e)
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            globalErrorHandler(ex, strError, oappweb.AppName, oappweb.UserName, False)
            Me.lblError.Text = ex.Message
        End Try
 
    End Sub
 
End Class

This is the calling page. It has the user control at the top of the page, providing a consistent menu interface

Public Class ProjectSummary
    Inherits InheritedPage
 
    Private Sub ProjectSummary_Init(sender As Object, e As EventArgs) Handles Me.Init
        'register for the event from the user control
        AddHandler ProjectSummaryMenu.ProjectSummaryMenu_MenuSelectionMade, AddressOf MenuSelectionMade
 
    End Sub
 
    Private Sub MenuSelectionMade(sender As Object, e As RadMenuEventArgs)
 
        'this code fires when the user clicks on a menu item in the user control. The event is raised in the user control and handled here in the parent form.
        Dim strMenuSelection As String = e.Item.Value.ToUpper
 
        Select Case strMenuSelection
            Case "ACTIVE"
                Response.Redirect("ProjectSummaryActive.aspx")
 
        End Select
 
 
    End Sub
End Class

 

 

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences