Skip to main content
added 390 characters in body
Source Link
Paweł Bejger
  • 6.3k
  • 23
  • 27

You should do this from jQuery level:

   $( ".selector" ).datepicker( "setDate", yourDate);

For example, if you want to set the today's date:

   $( ".selector" ).datepicker( "setDate", new Date());

You can also try adding the DisplayFormat attribute in your view model class to make sure that the date picker will interpret your data format correctly:

public class EmployeeIndexViewModel
{
    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
    public DateTime ToDate { get; set; }
}

You should do this from jQuery level:

   $( ".selector" ).datepicker( "setDate", yourDate);

For example, if you want to set the today's date:

   $( ".selector" ).datepicker( "setDate", new Date());

You should do this from jQuery level:

   $( ".selector" ).datepicker( "setDate", yourDate);

For example, if you want to set the today's date:

   $( ".selector" ).datepicker( "setDate", new Date());

You can also try adding the DisplayFormat attribute in your view model class to make sure that the date picker will interpret your data format correctly:

public class EmployeeIndexViewModel
{
    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
    public DateTime ToDate { get; set; }
}

You should do this from jQuery level:

   $( ".selector" ).datepicker( "setDate", yourDate);

So e.g.For example, if you want to set the today's date:

   $( ".selector" ).datepicker( "setDate", new Date());

You should do this from jQuery level:

   $( ".selector" ).datepicker( "setDate", yourDate);

So e.g. if you want to set the today's date:

   $( ".selector" ).datepicker( "setDate", new Date());

You should do this from jQuery level:

   $( ".selector" ).datepicker( "setDate", yourDate);

For example, if you want to set the today's date:

   $( ".selector" ).datepicker( "setDate", new Date());
Source Link
Paweł Bejger
  • 6.3k
  • 23
  • 27

You should do this from jQuery level:

   $( ".selector" ).datepicker( "setDate", yourDate);

So e.g. if you want to set the today's date:

   $( ".selector" ).datepicker( "setDate", new Date());