Q:

asp.net vb user control raising an event on the calling page

i'm trying to learn about user controls.  I created a user control that has a textbox and a button.  What i'd like to be able to do is when i click the button in the user control, populate a label in the aspx page.  I understand that i could just have  a button on the page that uses some properties on the user control to get that information.. but i'd like to know how to do it with the button the user control..  the reason for this is the button is just an example.. a learning tool.  if i can get this working, i'd likely be putting thing in the user control that might require this kind of passing information.  Anyway.. i've found some c# examples that i tried to get working as vb.. but once started getting into the delegates and events.. well.. it made me turn to this post.
anyway.. hopefully someone can lend a hand.

A:

See if this tutorial can help. The best way to do this is definitely to wire up an event, which isn't nearly as hard as you think. The basics are:
1. Define an event in your control class:
Public Event MyEvent as System.EventHandler
2. Raise the event in a sub or function of your control class:
RaiseEvent MyEvent(Me, New EventArgs())
3. Handle the event on the page that contains your control:
Protected Sub MyControl_MyEvent(ByVal sender As Object, ByVal e As EventArgs) Handles MyControl.MyEvent
    'Do stuff here
End Sub

