N
news.iq.ca
Hello,
I have created a UserControl (actually, a From/To control, containing two
list boxes and four buttons: MoveLeft, MoveAllLeft, MoveRight,
MoveAllRight). It works fine, but now I need to raise the following two
events so that in the container I can, depending on whether the "TO" list is
empty or not, enable or not the "Next Page" button.
In the control (ListToFrom.ascx), the code looks like this:
----------------------------------------------------------------
Protected WithEvents lstFrom As System.Web.UI.WebControls.ListBox
Public Event ListFrom_Empty()
Protected WithEvents lstTo As System.Web.UI.WebControls.ListBox
Public Event ListTo_Empty()
Protected WithEvents cmdRight As System.Web.UI.WebControls.Button
Protected WithEvents cmdRightAll As System.Web.UI.WebControls.Button
Protected WithEvents cmdLeft As System.Web.UI.WebControls.Button
Protected WithEvents cmdLeftAll As System.Web.UI.WebControls.Button
blah, blah, blah, and:
Private Sub lstFrom_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lstFrom.SelectedIndexChanged
If lstFrom.Items.Count = 0 Then RaiseEvent ListFrom_Empty()
End Sub
Private Sub lstTo_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lstTo.SelectedIndexChanged
If lstTo.Items.Count = 0 Then RaiseEvent ListTo_Empty()
End Sub
----------------------------------------------------------------
In the container, I have:
----------------------------------------------------------------
<%@ Register TagPrefix="Raducu" TagName="ListToFrom" src="ListToFrom.ascx"%>
----------------------------------------------------------------
But I can't receive the events raised by the UserControl (I can't define it
as being "withevents").
I tried
Private WithEvents m_objListToFrom As ListToFrom
and, yes, I can see the events, but this is NOT my Usercontrol, so the real
event never actually occurs:
----------------------------------------------------------------
Private Sub m_objListToFrom_ToEmpty() Handles m_objListToFrom.ListTo_Empty
cmdNext.Enabled = True
End Sub
----------------------------------------------------------------
How can I, then, wire these events ? Should I use AddHandler ? In so, how ?
Thank you.
Alex
I have created a UserControl (actually, a From/To control, containing two
list boxes and four buttons: MoveLeft, MoveAllLeft, MoveRight,
MoveAllRight). It works fine, but now I need to raise the following two
events so that in the container I can, depending on whether the "TO" list is
empty or not, enable or not the "Next Page" button.
In the control (ListToFrom.ascx), the code looks like this:
----------------------------------------------------------------
Protected WithEvents lstFrom As System.Web.UI.WebControls.ListBox
Public Event ListFrom_Empty()
Protected WithEvents lstTo As System.Web.UI.WebControls.ListBox
Public Event ListTo_Empty()
Protected WithEvents cmdRight As System.Web.UI.WebControls.Button
Protected WithEvents cmdRightAll As System.Web.UI.WebControls.Button
Protected WithEvents cmdLeft As System.Web.UI.WebControls.Button
Protected WithEvents cmdLeftAll As System.Web.UI.WebControls.Button
blah, blah, blah, and:
Private Sub lstFrom_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lstFrom.SelectedIndexChanged
If lstFrom.Items.Count = 0 Then RaiseEvent ListFrom_Empty()
End Sub
Private Sub lstTo_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lstTo.SelectedIndexChanged
If lstTo.Items.Count = 0 Then RaiseEvent ListTo_Empty()
End Sub
----------------------------------------------------------------
In the container, I have:
----------------------------------------------------------------
<%@ Register TagPrefix="Raducu" TagName="ListToFrom" src="ListToFrom.ascx"%>
----------------------------------------------------------------
But I can't receive the events raised by the UserControl (I can't define it
as being "withevents").
I tried
Private WithEvents m_objListToFrom As ListToFrom
and, yes, I can see the events, but this is NOT my Usercontrol, so the real
event never actually occurs:
----------------------------------------------------------------
Private Sub m_objListToFrom_ToEmpty() Handles m_objListToFrom.ListTo_Empty
cmdNext.Enabled = True
End Sub
----------------------------------------------------------------
How can I, then, wire these events ? Should I use AddHandler ? In so, how ?
Thank you.
Alex