SearchBox not working
I've created a WebUserControl that contains a Sitefinity SearchBox control. The SearchBox renders, but pressing Enter or clicking the Search button does not fire any events.
Here is my SearchBox markup:
<
sf:SearchBox
ID
=
"SearchTextBox"
BinderBoxLabelText
=
""
UseSearchButton
=
"true"
IndexCatalogue
=
"static-pages"
ResultUrl
=
"~/search-results"
runat
=
"server"
></
sf:SearchBox
>
<
div
id
=
"SearchBar1_SearchTextBox"
indexcatalogue
=
"static-pages"
resulturl
=
"~/search-results"
>
<
fieldset
class
=
"sfSearchBoxSet"
>
<
label
style
=
"text-indent: 0pt;"
for
=
"SearchBar1_SearchTextBox_ctl00_searchBox"
id
=
"SearchBar1_SearchTextBox_ctl00_lblSearchBox"
class
=
"sfSearchLbl"
></
label
>
<
input
name
=
"ctl00$SearchBar1$SearchTextBox$ctl00$searchBox"
id
=
"SearchBar1_SearchTextBox_ctl00_searchBox"
class
=
"sfTxt"
type
=
"text"
>
<
a
onclick
=
"return false;"
id
=
"SearchBar1_SearchTextBox_ctl00_searchButton"
class
=
"sfLinkBtn"
href
=
"javascript:__doPostBack('ctl00$SearchBar1$SearchTextBox$ctl00$searchButton','')"
>
<
strong
class
=
"sfLinkBtnIn"
>
Search
</
strong
>
</
a
>
</
fieldset
>
<
div
id
=
"SearchBar1_SearchTextBox_ctl00_searchProgressPanel"
style
=
"display: none;"
class
=
"sfSearchLoading"
>
<
img
id
=
"SearchBar1_SearchTextBox_ctl00_loadingImage"
src
=
"/WebResource.axd?d=slr4pCa-3AjAUDyrsWgIil8LU8NsXf9JqpUTZaDiPSVJBayA95TqHSo0xd8dUQTGbZTpXABiMQbllIjHTWj-ZmiJ7QYn7jo0fG0naJg5Gt-fdMAmIeUZi8ysAI9x9WatQbN6E758oomL7ml22WDEWQe4xffjp5kGyBbSpc0zX1npq5dbi36YdsLXYH3PMnU9q1FzKI_gkHjVc4ZzqHUjOJRlK9i9nYw0Xjpxyz5uozQ1&t=634352656706907585"
alt
=
"Searching..."
>
</
div
>
<
script
type
=
"text/javascript"
>
$('#SearchBar1_SearchTextBox_ctl00_searchBox').focus(function()
$("#SearchBar1_SearchTextBox_ctl00_lblSearchBox").css("text-indent","-99999px");
);
$('#SearchBar1_SearchTextBox_ctl00_searchBox').blur(function()
if ($(this).val() === '')
$("#SearchBar1_SearchTextBox_ctl00_lblSearchBox").css("text-indent","0");
else
$("#SearchBar1_SearchTextBox_ctl00_lblSearchBox").css("text-indent","-99999px");
);
$('#SearchBar1_SearchTextBox_ctl00_lblSearchBox').click(function()
var id, field;
id = $(this).attr("for");
if (id && (field = $("#"+id)))
field.focus();
);
$('#SearchBar1_SearchTextBox_ctl00_searchBox').blur();
//hideFormLabel($('#SearchBar1_SearchTextBox_ctl00_searchBox'),false);
</
script
>
</
div
>
Hello Chris,
From the declaration of the SearchBox that I see, this code would not work under the previous version as well. You should specify the SearchIndexPipeId property which is the index pipe ID.
Kind regards,
Ivan Dimitrov
the Telerik team
SearchIndexPipeId is not recognized as a valid attribute to the SearchBox control according to intellisense. It was my understanding that the IndexCatalogue attribute was used to specify the search index.
Changing my SearchBox definition to the following did not fix it:
<
sf:SearchBox
ID
=
"SearchTextBox"
SearchIndexPipeId
=
"static-pages"
BinderBoxLabelText
=
""
UseSearchButton
=
"true"
IndexCatalogue
=
"static-pages"
ResultUrl
=
"~/search-results"
runat
=
"server"
></
sf:SearchBox
>
Hello Chris ,
SearchIndexPipeId property which is the index pipe ID. As I see you use a some string that is not ID. Please check the declaration properly with the pipe ID.
Greetings,
Ivan Dimitrov
the Telerik team
Forgive my ignorance, but I don't know what you're referring to...
"SearchIndexPipeId" does not appear to be a public property of the SearchBox control. It does not appear in the intellisense when referencing Telerik.Sitefinity.Web.UI.
Assuming that SearchBox does actually accept the SearchIndexPipeId property, where do I go about finding this ID for a particular search index?
Can you provide me with a working code snippet?
Hi Chris,
This control cannot work if you do not set set SearchIndexPipeId public property. Gets or sets the ID of the search index pipe from which the search catalogue is resolved. The easiest way to get the pipe Id is to make a query to [sf_publishing_pipe_settings] table of the database
Regards,
Ivan Dimitrov
the Telerik team
I obtained the pipe id from the database and I'm setting the public property as follows:
<
sf:SearchBox
ID
=
"SearchTextBox"
SearchIndexPipeId
=
"87904a9c-f50c-4a60-ba59-fa72f209d61b"
BinderBoxLabelText
=
""
UseSearchButton
=
"true"
IndexCatalogue
=
"static-pages"
ResultUrl
=
"~/search-results"
runat
=
"server"
></
sf:SearchBox
>
Hi Chris,
I am not able to replicate this issue with Sitefinity 4.0 SP1 and Sitefinity 4.1 (Q1 ) release. If you use an older version, please upgrade your project.
Greetings,
Ivan Dimitrov
the Telerik team
I've upgraded to 4.1, and now the SearchBox control is no longer found underTelerik.Sitefinity.Web.UI.
Has this control moved to another namespace?
Under Telerik.Sitefinity.Web.UI, I did find a "BackendSearchBox" control; however, this control does not have public properties for ResultsUrl, IndexCatalogue, or SearchIndexPipeId.
Can you send me the correct Assembly and Namespace, as well as a snippet of markup to render the control?
Thank you!
Hi ,
The namespace hasn't been changed
Telerik.Sitefinity.Services.Search.Web.UI.Public - the public search box control.
Kind regards,
Ivan Dimitrov
the Telerik team