This project is read-only.

Search page not showing correct search term

Topics: ASP.NET 2.0
Jan 30, 2011 at 7:29 AM

Once you end up on the search page (search.aspx) with your initial search, if you then enter a new search word and press enter in the text field, the page refreshes but with the previous search term.  If however on the new search term, instead of pressing enter, you click the 'search' button, the page refreshes with the correct search term.

For the instance where this doesn't work (pressing enter in the text field), I see that the Page OnLoad method is called twice.  First with the correct search term, then secondly with the previous/incorrect search term.

Is anyone else having this same issue?

Jan 30, 2011 at 10:00 AM

I see that happening too -- at least the part about hitting enter and it reverting back to the original search term (I didn't check for Page OnLoad firing twice).

I think it can be fixed with some JavaScript to capture the enter key.  There is some JS on it actually, but it doesn't look like it's getting the job done.

It looks like when hitting Enter, the Search button is being activated causing a POST to the server.  This is something that browsers usually just do by default, but it can be circumvented by intercepting this process via JavaScript.  The JS needs to be improved to get it to work correctly.

Good find.