在UserControl中宣告事件:
Public Event DataChanged(ByVal s As String) '宣告事件 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click RaiseEvent DataChanged("Hello") '在按鍵被點下時引發事件並傳出資料 End Sub
在網頁中處理事件:
Protected Sub WebUserControl1_DataChanged(ByVal s As String) Handles WebUserControl1.DataChanged Label1.Text = s '利用UserControl傳出的資料更新網頁顯示的內容 End Sub