Web Custom Control Events
I created a web custom control which is derived from TextBox. I need to use the event OnTextChanged, but could not make it work. Similar code works for Button control.
To reproduce the problem, add the two custom controls to a webform. Add a break point sin the OnClick and OnTextChanged events and run the application.
I do not know what make the difference, and how to make the derived TextBox working.
Thank you very much for your help.
Jerry
Code for the derived textbox:
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class PBTextBox
Inherits System.Web.UI.WebControls.TextBox
Public Sub New()
Me.Width = System.Web.UI.WebControls.Unit.Pixel(60)
End Sub
Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
MyBase.OnTextChanged(e)
End Sub
End Class
Code for the derived Button
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
' custom control derives from button
Public Class CountedButton
Inherits System.Web.UI.WebControls.Button
' constructor initializes view state value
Public Sub New()
End Sub
' override the OnClick to increment the count,
' update the button text and then invoke the base method
Protected Overrides Sub OnClick(ByVal e As EventArgs)
'ViewState("Count") = CInt(ViewState("Count")) + 1
MyBase.OnClick(e)
End Sub
End Class
|