Page 1 of 1
Enter Key not working for Search
Posted: Sun Feb 14, 2010 1:38 pm
by Mike718NY
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
Re: Enter Key not working for Search
Posted: Mon Feb 15, 2010 9:27 am
by Mike718NY
It works in FireFox but not in IE 8, which unfortunately 70% of the
customers are using.
Re: Enter Key not working for Search
Posted: Mon Feb 15, 2010 9:32 am
by mazhar
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.
Re: Enter Key not working for Search
Posted: Mon Feb 15, 2010 10:35 am
by Mike718NY
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}; "
Re: Enter Key not working for Search
Posted: Mon Feb 15, 2010 2:51 pm
by Mike718NY
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?
Re: Enter Key not working for Search
Posted: Tue Feb 16, 2010 8:42 am
by Mike718NY
Anyboby know anything about JavaScript?
That seems to be the problem but I'm not javascript master.
Re: Enter Key not working for Search
Posted: Wed Feb 17, 2010 12:46 pm
by Mike718NY
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?