views:

21

answers:

1

Right now when I click on the date control, I start up at the year 2000! How can I tell it to start showing the current month of the current year?

Thanks!

<script type="text/javascript">
        $(document).ready(function () {
            $('#DOB').datepicker({ defaultDate: null });

        });
</script>

With the code above when I click the control I get July 2000 as the starting date.

+1  A: 

Set the defaultDate parameter. This works if the attached field is blank. See here:

http://docs.jquery.com/UI/Datepicker#option-defaultDate

Palantir
Please see edit, I'm using null (docs say that defaults to today) but I still get July 2000 as the starting date. Thanks.
Serg
The link I provided contains an example, try looking at that and return if there is something you don't understand. By saying that the fields should be blank I mean that there should be nothing in the field. If there is something, then that will be interpreted as date. The datepicker should be attached to an input field.
Palantir
Your code will not work, in the defaultDate option you need to specify the default date in the current date format (it will be a string).
Palantir
I don't understand. I could do this by using ASP.Net's DateTime.Now, and formatting it, but code will smell a lot. Can't you specify this with jQuery UI itself?
Serg
You have a form, and an input of type text, to which the datepicker is attached -- right? If the input is empty, then the datepicker should show your current day by default. You can change it using the defaultDate parameter. If the input is NOT empty, then the datepicker will get its contents and convert it to a datetime... So you should either leave the input empty, OR pre-fill it with the current date using asp.Net.
Palantir