I have built a custom control, which inherits from drop down list, and
“adds” an additional property, called “Text”
What I am trying to do, is to have the custom control itself perform an action (in this case setting one of it's properties to a value) - whenever an event is raised. I want the control itself to handle this, rather than having a situation where the "client" (code-behind on the page) traps the event raised, and sets the property - I want to shift this work to the control itself.
I can't seem to do this - tried to "add" some code to section where event handler is attached - does not seem to do the trick.
Thanking you in advance!
Chris
*************************************
Public Class ddlDataBind
Inherits DropDownList
Public Property Text() As String Implements
FullersInterfaces.DataInterface.Text
Get
Return _Text
End Get
Set(ByVal Value As String)
_Text = Value
SetSelectedItem()
End Set
End Property
Public Sub New()
MyBase.New()
AddHandler Me.selectedindexchanged, AddressOf indexchanged
End Sub
Private Sub indexchanged(ByVal sender As Object, ByVal e As EventArgs)
Me.Text = "Hello"
_Text = "Hello"
onchange(EventArgs.Empty)
End Sub
Protected Sub onchange(ByVal e As EventArgs)
Me.Text = "Hello"
_Text = "Hello"
RaiseEvent selectedindexchanged(Me, e)
End Sub
************************************************
Please help
Regards
Chris
“adds” an additional property, called “Text”
What I am trying to do, is to have the custom control itself perform an action (in this case setting one of it's properties to a value) - whenever an event is raised. I want the control itself to handle this, rather than having a situation where the "client" (code-behind on the page) traps the event raised, and sets the property - I want to shift this work to the control itself.
I can't seem to do this - tried to "add" some code to section where event handler is attached - does not seem to do the trick.
Thanking you in advance!
Chris
*************************************
Public Class ddlDataBind
Inherits DropDownList
Public Property Text() As String Implements
FullersInterfaces.DataInterface.Text
Get
Return _Text
End Get
Set(ByVal Value As String)
_Text = Value
SetSelectedItem()
End Set
End Property
Public Sub New()
MyBase.New()
AddHandler Me.selectedindexchanged, AddressOf indexchanged
End Sub
Private Sub indexchanged(ByVal sender As Object, ByVal e As EventArgs)
Me.Text = "Hello"
_Text = "Hello"
onchange(EventArgs.Empty)
End Sub
Protected Sub onchange(ByVal e As EventArgs)
Me.Text = "Hello"
_Text = "Hello"
RaiseEvent selectedindexchanged(Me, e)
End Sub
************************************************
Please help
Regards
Chris