Over the past week our team has been crunching out an asp.net webforms app to help manage our flood response situation that has been a very unfortunate side effect of the fire here in Coconino County. We have been going pretty fast, releasing one to two updates a day in order to get functionality out quickly to those who need it.
Today, we had a breather and I decided to go back and spruce up our work. One item on my plate was to help the users more easily enter dates. The main entry form has over 10 date fields. A little excessive but it’s what they need. I could just use the AJAX calendar extender but that would mean quite a bit of clicking and properties to set manually.
I had a hunch that the jQuery way may have an easier solution. Using Selectors, the solution ended up being one line of code.
How awesome is that. All of our date inputs have a prefix of 'dte' allowing a simple selector over all inputs with 'dte' in the name attribute. Normally, one would give all date inputs a class that can be use instead but they all already had this in common.
With the same idea in mind, I decided to change all of our buttons to use the jQuery button widget to get a nice and quick improvement on the look and feel.
In our case, we defined buttons two different ways in our code. Again, with selectors we can handle this with one line of code.
Downloading and using jQuery UI couldn’t be simpler. I customized the download (you don’t have to) to only use the date picker and button widgets and added the customized jQuery to a script tag. jQuery UI depends on jQuery but instead of using the version downloaded I used the google CDN to help speed things up a bit. Last, I added the theme for the controls to the app and referenced the stylesheet.
<link href="~/stylesheets/jqueryUIcss/ui-lightness/jquery-ui-1.8.2.custom.css" rel="Stylesheet" type="text/css" />
The ability to do this so easily and quickly with jQuery is a big WIN. I wonder if this is easily replicated with MS AJAX? My hunch is it’s probably doable but can’t possibly be easier and I imagine it’s not nearly as easy. I could be wrong though…