SearchBox not working

Posted by Community Admin on 03-Aug-2018 14:53

SearchBox not working

All Replies

Posted by Community Admin on 19-Apr-2011 00:00

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>

Looking at the generated source, I don't see where any onclick events are being wired up:
<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>

Is there something I'm doing wrong?

Thanks,
-Chris B.

Posted by Community Admin on 19-Apr-2011 00:00

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


Posted by Community Admin on 19-Apr-2011 00:00

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>

Any of thoughts?

Posted by Community Admin on 20-Apr-2011 00:00

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


Posted by Community Admin on 20-Apr-2011 00:00

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?

Posted by Community Admin on 21-Apr-2011 00:00

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


Posted by Community Admin on 21-Apr-2011 00:00

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>

However, SearchIndexPipeId is still not recognized as a public property.  When viewing intellisense properties on SearchTextBox from the code behind, this property does not exist.

The search button does nothing when I click on it, and pressing Enter while in the search textbox causes a page refresh, but does no redirect to the search results page.

I'm still on version 4.0.  Was this broken in 4.0 and fixed in a recent release?

Posted by Community Admin on 22-Apr-2011 00:00

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


Posted by Community Admin on 23-Apr-2011 00:00

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!

Posted by Community Admin on 25-Apr-2011 00:00

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


This thread is closed