Newbie - Rendered controls not firing events - help please

P

Paul

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.RaisePostDataChangedEven
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.RaisePostDataChangedEven
t
OnSearchRequired2(EventArgs.Empty)

End Sub

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

End Class
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top