Hi Peter,
I am trying to develop custom search control where I am using tabstrip UI similar to what appears in search pop-up control through Tools menu of ViewCollection.ascx control. But instead of using callback similar to ViewCollection.ascx, I want to bind search results on button click event. Please find the code written in button click event handler as follows:
Protected Sub lnkbtnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkbtnSearch.Click
Select Case TabStrip2.SelectedTab().Value()
Case "rawsearch"
Dim strRaw As String = txtRawSearch.Text
SearchController.Search(Me.PortalId, Session.SessionID, strRaw, Me.Settings.ModuleSettings.BaseRootId, True, True, True)
Case "regularsearch"
Case Else
'quick search
Dim strSearchTerm As String = txtQuickSearch.Text.Trim()
Dim iCollectionId As Integer = Me.Settings.ModuleSettings.BaseRootId
Dim lstSearchTerms As System.Collections.Generic.List(Of SearchTerm) = New System.Collections.Generic.List(Of SearchTerm)
Select Case rblFields.SelectedValue
Case "all"
Case "core"
Dim obj As SearchTerm = New SearchTerm()
obj.Field = "Title"
obj.Inclusion = IncludeType.Include
obj.Join = JoinType.Or
obj.SearchString = strSearchTerm
obj.Tokenize = False
lstSearchTerms.Add(obj)
Case Else
Dim obj As SearchTerm = New SearchTerm()
obj.Field = "title"
obj.Inclusion = IncludeType.Include
obj.Join = JoinType.Or
obj.SearchString = strSearchTerm
obj.Tokenize = False
lstSearchTerms.Add(obj)
End Select
Select Case rblScopeQ.SelectedValue
Case "folder"
Case "all"
iCollectionId = Me.Settings.ModuleSettings.BaseRootId
Case Else
iCollectionId = Me.Settings.ModuleSettings.BaseRootId
End Select
SearchController.Search(Me.PortalId, Session.SessionID, lstSearchTerms, iCollectionId, True, True, True)
End Select
Dim objSearchController As Bring2mind.DNN.Modules.DMX.Services.Search.SearchController = New Bring2mind.DNN.Modules.DMX.Services.Search.SearchController()
Dim results As Object = objSearchController.GetGridContents(Me.PortalSettings, Me.TabId, Me.ModuleId, Me.Settings.ModuleSettings, Me.UserInfo, Me.UserInfo.IsInRole("Administrator"), Session.SessionID)
If CType(results, System.Data.DataView).Table.Rows.Count > 0 Then
dgResults.DataSource = results
dgResults.DataBind()
End If
End Sub
With this code I am not getting expected results. "results" object doesn't contain any records for the search.
If I put last few lines of code starting from objSearchController declaration in Page_Load of control and before requesting the page where custom search control is placed, I search for the term in DNN+DMX Search,records similar to what are displayed on DMX search page are displayed in custom search control.
Hence I came to a conclusion that either I am missing something in Search() call or not using proper API call for search.
Appreciate your valuable suggestion.