How to Cache Search Criteria in ASP.NET
When developing nearly any application, one of the least considered aspects is unfortunately usability. Let’s be honest here, us developers are great at writing complex algorithms, designing database entity relationships and object oriented class structures, but when it comes down to the everyday user we often lose touch with what’s important.
Not that it’s entirely our fault, oftentimes a usability expert is just something not all developers have at their disposal. Having a key individual who has a strong grasp of the end user requirements is often your best source for usability.
Creating an easy to use application is a challenging task. Usability is a sum of all its parts, meaning an application must flow together and be logical on each page, as well as together as a whole. In this tutorial we’ll take one small piece of usability and implement it in such a way that it can even affect other pages.
The premise is quite simple, a lot of search pages, list pages or reports pages require several parameters as criteria, our goal is to cache these criteria so that the user can leave the page, return to the search page and have the criteria from the previous search pre-filled, and possibly re-execute the search automatically.
Entering information into forms is probably the most time consuming aspect of the end-users job, and probably the least considered from a developer, so this criteria caching pattern can really save your end users a lot of time.
We’ll implement a simple sample application in ASP.NET 1.1 with a search form, connected to a live database for demonstration purposes. The user can search, view the results, then navigate away from the page, and later return with the previous search fields pre-filled, all in a pattern which will keep the session clean and easy to read.
Visual Studio .NET 2002/2003 running ASP.NET 1.1 is required for this tutorial. Connection to an SQL or Access database is desirable however not required for understanding the cache pattern. The sample pubs SQL database will be used for demonstration in this tutorial. Both VB.NET and C# code samples will be provided