Page 1 of 1

Utility\SimpleSearch not working

Posted: Thu Oct 11, 2012 7:42 am
by Calbeth
Hey gang,

The prefabbed SimpleSearch control isn't working as is. No matter what I enter as my keyword search phrase, I receive the error message, "Search keyword must be at least 1 characters in length excluding spaces and wildcards." I'm not redirected to a results page under any circumstance. I'm on a fresh install of AC Gold (not upgraded from 7).

I discovered the problem while working on a customization of the control (intended to search products, specifically). I'm pretty certain I've traced the issue to the way the control is supposed to handle errors. Search starts working when I comment out the ASP Button control SearchButton, from validation group to close, as such (see lines 7-8):

Code: Select all

<div class="simpleSearchPanel">
    <asp:Panel ID="SearchPanel" runat="server" CssClass="innerSection">
		<asp:ValidationSummary ID="SearchValidation" runat="server" ShowMessageBox="true" validationgroup="Search" Visible="true"/>
        <asp:TextBox ID="SearchPhrase" runat="server" CssClass="searchPhrase" 
         	  Text="Search Products by Model # or Keyword" MaxLength="60"></asp:TextBox>
        <asp:Button ID="SearchButton" runat="server" Text="Search"
			 OnClick="SearchButton_Click" CausesValidation="true" /><!--validationgroup="Search"
			 onclientclick="if(Page_ClientValidate('Search')){{window.location='{0}?k='+encodeURIComponent({1}.value);}}return false;" />-->
		<cb:SearchKeywordValidator ID="SearchPhraseValidator" runat="server" ControlToValidate="SearchPhrase" 
			ErrorMessage="Search keyword must be at least {0} characters in length excluding spaces and wildcards."
			Text="*" ValidationGroup="Search" Display="None" KeywordRequired="true"></cb:SearchKeywordValidator>     
    </asp:Panel>
</div>
However, that only partially solves the problem. Search will work as long the keyword can be matched somewhere to the database. If there's no match, I get a StackTrace error:

Code: Select all

Server Error in '/store' Application.

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Source Error: 

Line 161:        {
Line 162:            Trace.Write(this.GetType().ToString(), "Begin BindProductList");
Line 163:            ProductList.DataSource = ProductDataSource.AdvancedSearch(_patternKeywords, _categoryId, _manufacturerId, true, true, true, 0, 0, _pageSize, (_hiddenPageIndex * _pageSize), SortResults.SelectedValue);
Line 164:            ProductList.DataBind();
Line 165:            NoSearchResults.Visible = (_searchResultCount == 0);
Any idea what might be causing the problem?

Re: Utility\SimpleSearch not working

Posted: Thu Oct 11, 2012 2:34 pm
by jmestep
We have a Gold R2 site in development and the search works there. I don't get an error if there are no results either.

Re: Utility\SimpleSearch not working

Posted: Thu Oct 11, 2012 4:12 pm
by Logan Rhodehamel
The second thing you mention about search having trouble if there are no matching items - I believe looks similar to another bug that was reported and will be fixed with our next update.