Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Newbie - Rendered controls not firing events - help please

Reply
Thread Tools

Newbie - Rendered controls not firing events - help please

 
 
Paul
Guest
Posts: n/a
 
      12-12-2003
Hello,
I have 2 user written rendered controls. If I put them on
a page one at a time they work OK. If i put them on the
page at the same time neither of the events fire.
Anybody help please?

---------------------------
aspx page

Public Class TestPage
Inherits System.Web.UI.Page
Protected WithEvents ST1 As CCControls.SearchTerm
Protected WithEvents lblST2 As
System.Web.UI.WebControls.Label
Protected WithEvents ST2 As CCControls.SearchTerm2
Protected WithEvents lblST1 As
System.Web.UI.WebControls.Label


#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub ST1_SearchRequired(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ST1.SearchRequired
lblST1.Text = ST1.SearchString
End Sub


Private Sub ST2_SearchRequired2(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
ST2.SearchRequired2
lblST2.Text = ST2.SearchString
End Sub
End Class

---------------------
control 1


Imports System.ComponentModel
Imports System.Web.UI

<DefaultProperty("SearchString"), ToolboxData("<
{0}:SearchTerm runat=server></{0}:SearchTerm>")> Public
Class SearchTerm
Inherits System.Web.UI.WebControls.WebControl
Implements IPostBackDataHandler

Private Const ImageHome As String
= "/changecontrol/images/banners/home.jpg"

Public Event SearchRequired As EventHandler

Public Property SearchString() As String
Get
Return viewstate("SearchString")
End Get

Set(ByVal Value As String)
viewstate("SearchString") = Value
End Set
End Property


Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.AddAttribute(HtmlTextWriterAttribute.Name,
UniqueID)
output.AddAttribute(HtmlTextWriterAttribute.Value,
SearchString)
output.RenderBeginTag(HtmlTextWriterTag.Input)
output.RenderEndTag()
End Sub

Public Function LoadPostData(ByVal postDataKey As
String, ByVal postCollection As
System.Collections.Specialized.NameValueCollection ) As
Boolean Implements
System.Web.UI.IPostBackDataHandler.LoadPostData
If SearchString <> postCollection(postDataKey) Then
SearchString = postCollection(postDataKey)
Return True
End If
Return False
End Function

Public Sub RaisePostDataChangedEvent() Implements
System.Web.UI.IPostBackDataHandler.RaisePostDataCh angedEven
t
OnSearchRequired(EventArgs.Empty)
End Sub

Public Sub OnSearchRequired(ByVal e As EventArgs)
RaiseEvent SearchRequired(Me, EventArgs.Empty)
End Sub
End Class


-------------------------------
control 2

Imports System.ComponentModel
Imports System.Web.UI

<DefaultProperty("SearchString"), ToolboxData("<
{0}:SearchTerm2 runat=server></{0}:SearchTerm2>")> Public
Class SearchTerm2
Inherits System.Web.UI.WebControls.WebControl
Implements IPostBackDataHandler

Public Event SearchRequired2 As EventHandler

Public Property SearchString() As String
Get
Return viewstate("SearchString2")
End Get

Set(ByVal Value As String)
viewstate("SearchString2") = Value
End Set
End Property

Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.AddAttribute(HtmlTextWriterAttribute.Name,
UniqueID)
output.AddAttribute(HtmlTextWriterAttribute.Value,
SearchString)
output.RenderBeginTag(HtmlTextWriterTag.Input)
output.RenderEndTag()
End Sub

Public Function LoadPostData(ByVal postDataKey As
String, ByVal postCollection As
System.Collections.Specialized.NameValueCollection ) As
Boolean Implements
System.Web.UI.IPostBackDataHandler.LoadPostData

If SearchString <> postCollection(postDataKey) Then
SearchString = postCollection(postDataKey)
Return True
End If
Return False

End Function

Public Sub RaisePostDataChangedEvent() Implements
System.Web.UI.IPostBackDataHandler.RaisePostDataCh angedEven
t
OnSearchRequired2(EventArgs.Empty)

End Sub

Public Sub OnSearchRequired2(ByVal e As EventArgs)
RaiseEvent SearchRequired2(Me, EventArgs.Empty)
End Sub

End Class

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically adding controls with events (but events are not firing) SevDer ASP .Net 2 11-13-2007 06:33 AM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
Events not firing (First time only) in a dynamic user control. Please help. =?Utf-8?B?U2hvdXJpZQ==?= ASP .Net 1 01-21-2004 10:31 PM
Programmatically creating a datagrid control - Events NOT Firing!!!! Please Help KJ ASP .Net Datagrid Control 0 08-11-2003 05:20 PM
Child controls in Composite Controls not firing events David Boike ASP .Net Web Controls 0 08-07-2003 05:39 PM



Advertisments