Problem:
This is a very common thing we all do. Ask the user to enter a date or a range of dates into a web form. The best way to ensure the format is to use the calendar control that comes with the ASP.NET framework. But these calendar controls are so huge that you'd only want to bring in to the page only when it is needed. There are many solutions offered on various web sites about how this is done.
The problem in most of the solution, at least for me, is that you need to understand or deal with JavaScript to open another window, pass some parameters to it, pass back more parameters and then finally to fill out the main form.
Many of us do not do web programming day in and day out and rather not have to deal with JavaScript (for that matter avoid any programming languages that start with a letter "J"). While he JS technique is definitely more elegant, we can hit the middle ground.
Solution:
One alternate solution that I came up with to take advantage of MultiView control. It is actually quite neat that you can basically create "layers" of panels that they call a View and expose any panel at your will. So for example in my case, I display a grid list of all previous surf stuff orders from past 30 days. When I need to ask for the date range, I have two calendar controls on another view asking for the first and last days, and I will bring that "forward." As soon as the second calendar control (for the last day) is clicked, I can trap the event for the Selected Date Changed, collect the new pair of dates from the controls, bring the view with the data grid again.
It is quite easy to do, just set whichever the view you would like to show in the MultiView control, and I did not touch a line of HTTP source code to do this.
Time Took To Figure Out
Once I've realized this possibility, it took me just about 30 min to confirm that this will work for me.
No comments:
Post a Comment