ASP.net: what's the best way to handle page cleanup?
I have a search page and the search result will be shown in a gridview control. I have a Clear button to clear the search result in the gridview as well as a textbox where the user enters search criteria.
I did a Cleanup first by doing a page refresh print("Response.Redirect(~/blah/search.aspx");
, but I'm not sure if this is the best way to clean the page. Would it be better to set the textbox to string empty and set the gridview datasource to Nothing and then bind it?
source to share
The best way to do this is not to do it at all.
Try to create a search box / buttons so it's obvious that you can initiate a new search simply by entering a text box and clicking the search button. Take a cue from Google. Most users are probably already familiar with this behavior.
If starting from scratch rather than refining the current search is the most common user behavior, then you can use some javascript to clear the focus search box. Or less intrusively, you can simply select the focus text to allow type styles to be erased.
onFocus="this.select()"
There should be no reason to waste server CPU / bandwidth or your user time searching from a blank page.
source to share