X
xamman
hello folks, when i added this custom control to my webform along with
a submit button and while debugging i found that the cached 'change'
event never gets fired when i key in text in the textbox. it will only
fire if you add a 'text' attribute in the html.
if the change event doesnt fire the viewstate wont be kept for this
textbox. any idea what i am doing wrong ?....thanks
x
Imports System.ComponentModel
Imports System.Web.UI
<DefaultEvent("OnChange")> Public Class WebCustomControl1
Inherits WebControls.WebControl
Event Change(ByVal sender As Object, ByVal e As EventArgs)
Property Text() As String
Get
If Not IsNothing(ViewState("Text")) Then
Return ViewState("Text")
Else
Return ""
End If
End Get
Set(ByVal Value As String)
ViewState("Text") = Value
OnChange(EventArgs.Empty)
End Set
End Property
Protected Overridable Sub OnChange(ByVal e As EventArgs)
RaiseEvent Change(Me, EventArgs.Empty)
End Sub
Protected Overrides Sub Render(ByVal output As _
System.Web.UI.HtmlTextWriter)
output.AddAttribute("value", Me.Text)
output.RenderBeginTag("Input")
output.RenderEndTag()
End Sub
End Class
a submit button and while debugging i found that the cached 'change'
event never gets fired when i key in text in the textbox. it will only
fire if you add a 'text' attribute in the html.
if the change event doesnt fire the viewstate wont be kept for this
textbox. any idea what i am doing wrong ?....thanks
x
Imports System.ComponentModel
Imports System.Web.UI
<DefaultEvent("OnChange")> Public Class WebCustomControl1
Inherits WebControls.WebControl
Event Change(ByVal sender As Object, ByVal e As EventArgs)
Property Text() As String
Get
If Not IsNothing(ViewState("Text")) Then
Return ViewState("Text")
Else
Return ""
End If
End Get
Set(ByVal Value As String)
ViewState("Text") = Value
OnChange(EventArgs.Empty)
End Set
End Property
Protected Overridable Sub OnChange(ByVal e As EventArgs)
RaiseEvent Change(Me, EventArgs.Empty)
End Sub
Protected Overrides Sub Render(ByVal output As _
System.Web.UI.HtmlTextWriter)
output.AddAttribute("value", Me.Text)
output.RenderBeginTag("Input")
output.RenderEndTag()
End Sub
End Class