Enter Key not working for Search

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Enter Key not working for Search

Post by Mike718NY » Sun Feb 14, 2010 1:38 pm

After typing in the Search box and hitting Enter, it stays on the
same page and won't go to Search page unless I hit the Search Button.

It gives this "Error on Page" error:

Webpage error details

Message: 'document.getElementById(...)' is null or not an object
Line: 125
Char: 85
Code: 0
URI: http://localhost/DCP3/Default.aspx

The same message for all other pages like Categories:
Message: 'document.getElementById(...)' is null or not an object
Line: 125
Char: 85
Code: 0
URI: http://localhost/DCP3/ADVENT-ITEMS-C371.aspx

Anyone know how this can be fixed? Thanks

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: Enter Key not working for Search

Post by Mike718NY » Mon Feb 15, 2010 9:27 am

It works in FireFox but not in IE 8, which unfortunately 70% of the
customers are using.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Enter Key not working for Search

Post by mazhar » Mon Feb 15, 2010 9:32 am

Try a quick fix I am not sure but it may work. Have a look at the source code of button. Is it a link button. If its a link button then simply change it to ASP Button and then again try it in IE.

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: Enter Key not working for Search

Post by Mike718NY » Mon Feb 15, 2010 10:35 am

The button in the code is "<asp:Button ID="SearchButton" runat="server" Text="GO!" ....
Should I change it to a ASP Link Button instead?

Here is the Source code from Default.aspx :

<input type="submit" name="ctl00$wpm$HomePage$ctl00$SearchButton" value="GO!"
onclick=
"if(Page_ClientValidate('Search')){window.location='/DCP3/Search.aspx?k='+encodeURIComponent(ctl00_wpm_HomePage_ctl00_SearchPhrase.value);}return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$wpm$HomePage$ctl00$SearchButton", "", true, "Search", "", false, false))"
id="ctl00_wpm_HomePage_ctl00_SearchButton" />

Code: Select all

I'm guessing the line below in ConLib\Custom\SimpleSearch.ascx.cs is causing the problem :

    string handleEnterScript = "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"
        + SearchButton.UniqueID + "').click();return false;}} else {return true}; ";

If I put a break point in and step into the line, the line above gives this:

"if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {
document.getElementById('ctl00$wpm$HomePage$ctl00$SearchButton').click();return false;}} else {return true}; "

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: Enter Key not working for Search

Post by Mike718NY » Mon Feb 15, 2010 2:51 pm

The ID in the Source is: id="ctl00_wpm_HomePage_ctl00_SearchButton"

But a break point in the code is showing:
document.getElementById('ctl00$wpm$HomePage$ctl00$SearchButton')

are the Question marks the problem and should be replaced by underscores?

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: Enter Key not working for Search

Post by Mike718NY » Tue Feb 16, 2010 8:42 am

Anyboby know anything about JavaScript?
That seems to be the problem but I'm not javascript master.

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: Enter Key not working for Search

Post by Mike718NY » Wed Feb 17, 2010 12:46 pm

The Search works on FireFox. I found one difference:

FireFox view source:
onclick="if(Page_ClientValidate('Search')){window.location='/Search.aspx?

IE8:
onclick="if(Page_ClientValidate('Search')){window.location='/DCP3/Search.aspx?

The Search page is in the root folder and this seems to be the problem.
Is anyone else experiencing this problem?

Post Reply