- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I'm reading this late, so maybe the text has been changed since you 2 commented, but there's nothing in the js that has anything to do with binding the Enter key (or any other key press for that matter). Here's the js that would be output:
It's definitely triggering the click event on the button, and since that's being registered as a startup script, it will run as soon as the page loads...Admin
I agree. There could be other javascript that is doing a ton of processing based on the value in the SearchTextBox. As others have said, since the querystring variable name is Input, it's probably to handle old bookmarks. It populates that value to the SearchTextBox and reloads the page, so any client-side code can work using that value, populate some other input fields, and then it automatically resubmits it, with the submission now including all the data needed for the server-side processing.
Yes, everything done on the client-side could most likely be done server-side also, and then directly call the Search() method. However, you would then have the same logic in 2 places: Client-side for people going directly to the page, to reduce the amount of processing required server-side, and then server-side for the people with old bookmarks. If that logic is sufficiently complex, then it could make sense to do it this way, rather than duplicating the logic, and having to maintain it in 2 different places.
Admin
If "SearchImageButton" were wrapped inside an UpdatePanel the click event would trigger an ajax partial postback rather than a full postback, allowing the search results to be populated after the initial load without reloading the whole page. In which case, as others have said, the page would be perceived as loading faster.
Admin
Uhhhh, the WTF is on the very first line:
...that's ASP.NET, not Javascript; they're using server-side scripting to dynamically insert their client-side scripts, for no apparent reason.