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?

0


source to share


4 answers


I prefer the redirect method for several reasons:



  • Use can hit and get data back.
  • Less code to keep remember when page changes. (If you add a new field, do you also remember to clear it?)
+3


source


I'd rather clear the textbox and bind the gridview to empty lists.



+1


source


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.

+1


source


I usually just create a link that says "New Search" (since you're starting, not just clear the form, which means "Clear" to me) that points to the search page instead of submitting to avoid unnecessary redirect-only postbacks.

0


source







All Articles