event bubbling

2 posts, 0 answers
  1. Christian Devita
    Christian Devita avatar
    34 posts
    Member since:
    Jun 2005

    Posted 22 May 2015 Link to this post

    I'm having a problem trying to bubble the search server event from within a template.

    I am programmatically creating my controls. The SearchBox control is in the LayoutTemplate of a RadListView control. I also have a RadToolBar which seems to have no problem bubbling events from within that template.

    Here is sample code 


    Public Class RadListViewLayoutTemplate

        Inherits Control
        Implements ITemplate

        Public Sub New()

        End Sub

        Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn

            Dim RadSearchBox1 As New Telerik.Web.UI.RadSearchBox
            RadSearchBox1.ID = "RadSearchBox1"

            AddHandler RadSearchBox1.Search, AddressOf RadSearchBox1_Search

            container.Controls.Add(New LiteralControl(" "))

            Dim RadSearchToolBar1 As New Telerik.Web.UI.RadToolBar
            RadSearchToolBar1.ID = "RadSearchToolBar1"

            Dim AdvancedSearchButton As New Telerik.Web.UI.RadToolBarButton
            AdvancedSearchButton.Text = Resources.WebResources.AdvancedSearch

            AdvancedSearchButton.CommandName = "AdvancedSearch"

            AddHandler RadSearchToolBar1.ButtonClick, AddressOf RadSearchToolBar1_ButtonClick

      End Sub

       Protected Sub RadSearchBox1_Search(sender As Object, e As Telerik.Web.UI.SearchBoxEventArgs)

            MyBase.RaiseBubbleEvent(Me, New CommandEventArgs("Search",e.Text ))

        End Sub

        Protected Sub RadSearchToolBar1_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs)
            If TypeOf e.Item Is Telerik.Web.UI.RadToolBarButton Then
                Dim RadToolBarButton1 As Telerik.Web.UI.RadToolBarButton = CType(e.Item, Telerik.Web.UI.RadToolBarButton)
                Select Case RadToolBarButton1.CommandName
                    Case "AdvancedSearch"
                        MyBase.RaiseBubbleEvent(Me, New CommandEventArgs("AdvancedSearch", Nothing))
                End Select
            End If
        End Sub

    End Class

  2. Aneliya Petkova
    Aneliya Petkova avatar
    207 posts

    Posted 27 May 2015 Link to this post

    Hello Christian,

    I made a sample project using the code you sent and everything works correctly at my side. Here you may find a video showing that the RadSearchBox's server-side event fires on search. Attached is the project I used for testing. If I am missing something, please modify the project in order to show me the issue.

    Aneliya Petkova
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top