In a project I'm currently working for we've stumbled upon the need for several kinds of search results presentation controls. The search result are similar, but not identical. For example, in the "office search" result we might want to present the office name and location, while in the "document search" could contain document name, author and publishing date. These fields should be sortable.
My current strategy is to employ the Factory pattern and do something like this:
ISearchResult officeResults = SearchResultFactory.CreateOfficeSearchResults(data);
ISearchResult documentResults = SearchResultFactory.CreateDocumentSearchResults(data);
The problem is: I don't know how to implement the markup code. Should I just do
Controls.Add(officeResults);
in the containing page? Or is there some ASPX trickery to create generic web controls? Or maybe I'm overthinking this and just should create five classes? ;)