another sleepless night- cust control event not firing


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
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top