This is a migrated thread and some comments may be shown as answers.

event bubbling

1 Answer 111 Views
SearchBox
This is a migrated thread and some comments may be shown as answers.
Christian Devita
Top achievements
Rank 1
Christian Devita asked on 22 May 2015, 05:02 PM

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(RadSearchBox1)

        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"
        RadSearchToolBar1.Items.Add(AdvancedSearchButton)

        AddHandler RadSearchToolBar1.ButtonClick, AddressOf RadSearchToolBar1_ButtonClick
        container.Controls.Add(RadSearchToolBar1)

  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

1 Answer, 1 is accepted

Sort by
0
Aneliya Petkova
Telerik team
answered on 27 May 2015, 09:53 AM
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.

Regards,
Aneliya Petkova
Telerik
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
Tags
SearchBox
Asked by
Christian Devita
Top achievements
Rank 1
Answers by
Aneliya Petkova
Telerik team
Share this question
or