More DatePickers!

In continuation of my previous post on jQuery UI, I updated the project on CodePlex with a demo of how multiple date pickers can be included. It’s very simple, just requires a little bit of nifty JavaScript. In fact, it’s a one-liner.


$("*[id*=date]").datepicker();

Yep! That simple. This will activate the date picker on every element whose id has "date"-something in it. Like so:


@Html.TextBoxFor(model => model.DateTime1, new { id = "date1" })
@Html.TextBoxFor(model => model.DateTime2, new { id = "date2" })

Here’s a screenshot of how that looks:

Get the project from CodePlex and play around. I will be updating it soon again.

Advertisements

3 Comments on “More DatePickers!”

  1. ali62b says:

    Thanks for the update it works like a clock!
    Keep up the great work…

  2. Shahnawaz Alam says:

    Thanks for sharing. I have a basic question for you, I know little about web technologies. So I’m making an event management section for larger ASP.NET site and we all know that ASP.NET takes is slower than other things out there. If the calender is made with asp.net then it might load slower, so if this jQuery date picker is used instead can the date picked here be used in C# later for other functionalities (let’s say storing notes or uploading a file) or is it just better to use the the stuff VS provides.

    • aredkid says:

      Dude! It’s me… what’s with the formal tone?

      Anyway, I am guessing you’re talking about the controls that are there in .Net. They have their place in WebForms but nowadays the standard is to use controls built with plain HTML and CSS with JavaScript doing the hard work. And making things easy are frameworks like jQuery, MooTools etc.

      Good luck deving!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s