Friday, September 5, 2008

Auto Save/load Template Server Control

Recently my team had a requirement where they wanted to store the search criteria on various screen under user's profile. So that once the user selects some search criteria on a particular screen, next time when he comes back to the same screen it should re load those search criteria automatically. Now this could have been accomplished by changing the screens to store the search criteria during post back in the database and load them when the screen is loaded for the first time from the database for the user. But we had around 20-30 such screens, which means lot of code changes.

This is when we got the idea of designing the user control, and the outcome was great. Thanks to the user control all we had to do in those screens is just add the reference to the control and put all the asp .net/html controls within our user control. Total 2 lines of code change :)

The same control can be modified to achieve lot of other requirements like doing common validations, applying some common code to all the controls etc.

Read the article in detail at CodeProject, I have also uploaded complete source code for the control as well demo project.
http://www.codeproject.com/KB/webforms/vishalshukla.aspx

2 comments:

Catto said...

Hey Now Vishal,

Nice Post.

Thx 4 the info,

Catto

Vishal shukla said...

thanks Chris :)