Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Events and Delegates

  Asked By: Lamberta    Date: Mar 06    Category: Asp.net    Views: 634

I'm having a problem getting an event to fire in a usercontrol, which initiates
a subroutine in the page where the usercontrol resides. When I execute the
page, I receive no errors, but I'm not getting the results I would expect. What
am I doing wrong? (I have omitted most excess code for breviaty)

--Usercontrol (selectarea) codebehind
Public MustInherit Class SelectArea
Public Event MyEvent As MyEventDelegate
Public Delegate Sub MyEventDelegate(ByVal sender As System.Object, ByVal e
As System.EventArgs)
Sub btnSelectArea_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSelectArea.Click
Dim anItem As DataListItem
Dim blnIsChecked As Boolean
Dim intCheckedArea As Integer
Dim colSelectedArea As ArrayList
Dim chkSelected As System.Web.UI.WebControls.CheckBox
colSelectedArea = New ArrayList()
For Each anItem In dlstActiveAreas.Items
chkSelected = anItem.FindControl("chkAreaChoice")
If chkSelected.Checked Then
intCheckedArea = dlstActiveAreas.DataKeys(anItem.ItemIndex)
End If
RaiseEvent MyEvent(Me, e)
End Sub
End Class
---Page object (codebehind)
Public Class ViewAllBids
Inherits System.Web.UI.Page
Protected WithEvents lblMessage As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim objMyUserControl As SelectArea
objMyUserControl = CType(LoadControl("UserControls/SelectArea.ascx"),
AddHandler objMyUserControl.MyEvent, AddressOf ucSelectArea

End Sub
Private Sub ucSelectArea(ByVal sender As System.Object, ByVal e As
lblMessage.Text = "btnSelectArea Clicked"
End Sub
End Class

I figure, if this were working properly, I would see "btnSelectArea Clicked" in
the output on my webform.
Can anyone see what I've done wrong?



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Events and Delegates Or get search suggestion and latest updates.