Set calender control

Last post 10-13-2008 4:31 AM by shrikrishnabhardwaj. 4 replies.

Sort Posts:

  • Set calender control

    10-13-2008, 2:13 AM
    • Member
      78 point Member
    • werwin12
    • Member since 10-12-2005, 12:27 PM
    • Posts 133

    Is it possible to set the calender control with a string as 11/11/09?

  • Re: Set calender control

    10-13-2008, 4:13 AM
    Answer
    • Participant
      959 point Participant
    • PaulSpencer
    • Member since 09-11-2008, 10:42 AM
    • Amsterdam
    • Posts 185

    in source

            <asp:Calendar ID="Calendar1" runat="server" SelectedDate="2009-11-11"></asp:Calendar>

    ------------------------
    if an answer, mark it so.

    ------------------------
    if an answer, mark it so.
  • Re: Set calender control

    10-13-2008, 4:15 AM
    Answer
    • Participant
      959 point Participant
    • PaulSpencer
    • Member since 09-11-2008, 10:42 AM
    • Amsterdam
    • Posts 185

     in code behind:

    this.Calendar1.SelectedDate = DateTime.Parse("11/11/2009");

    ------------------------
    if an answer, mark it so.

    ------------------------
    if an answer, mark it so.
  • Re: Set calender control

    10-13-2008, 4:19 AM
    Answer
    • Participant
      959 point Participant
    • PaulSpencer
    • Member since 09-11-2008, 10:42 AM
    • Amsterdam
    • Posts 185

     or to make sure your dealing with the way the locals do their dates:

    DateTime.Parse("11/11/2009",CultureInfo.CurrentCulture)

    could also be doubly sure with

    DateTime.ParseExact("11/11/2009","dd/MM/yyyy",CultureInfo.CurrentCulture)

    ------------------------
    if an answer, mark it so.

    ------------------------
    if an answer, mark it so.
  • Re: Set calender control

    10-13-2008, 4:31 AM
    Answer

     

    1    string str_Date = "2008-12-29";
    2    Calendar1.SelectedDate = DateTime.Parse(str_Date);
    3    Calendar1.SelectionMode = CalendarSelectionMode.Day;
    4    Calendar1.TodaysDate = DateTime.Parse(str_Date);
    
      
    -
    Please "Mark As Answer" if this post is in accordance with your query, so that it could help other users to get rid of the same problem.
    Blog: Code Less With ASP.Net, SQL Server, Javascript
Page 1 of 1 (5 items)