Click here to Skip to main content
15,904,638 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void Calendarbutton_Click(object sender, EventArgs e)
       {
           this.monthCalendar1.Show();

       }

       private void DatetextBox_TextChanged(object sender, EventArgs e)
       {
           this.monthCalendar1.Hide();
       }

private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
       {
           // To display single selected of date
           monthCalendar1.MaxSelectionCount = 1;
           // To display single date use MonthCalendar1.SelectionRange.Start/ MonthCalendarSelectionRange.End
           this.DatetextBox.Text = monthCalendar1.SelectionRange.Start.ToString("dd-MMMM-yyyy", new System.Globalization.DateTimeFormatInfo());

       }


my problem it is not setting today's date and if I want to change the month it is disappearing

Thanks
Posted
Updated 9-Aug-11 8:46am
v2
Comments
Herman<T>.Instance 9-Aug-11 16:23pm    
is this the asp.net object or the ajax toolkit object?

1 solution

for asp.net control see http://msdn.microsoft.com/en-us/library/add3s294(v=VS.85).aspx[^]

for ajax control an example:
C#
cePickDateStart.Format = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
       cePickDateFinish.Format = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;

       if (!IsPostBack)
       {
           if (!cePickDateStart.SelectedDate.HasValue)
               cePickDateStart.SelectedDate = DateTime.Now.AddMonths(-1).AddDays(-DateTime.Now.Day+1);
           if (!cePickDateFinish.SelectedDate.HasValue)
               cePickDateFinish.SelectedDate = DateTime.Now.AddDays(-DateTime.Now.Day + 1);


           txtPickDateStart.Text = cePickDateStart.SelectedDate.Value.ToShortDateString();
           txtPickDateFinish.Text = cePickDateFinish.SelectedDate.Value.ToShortDateString();
           LoadUserPageVisits();
       }
       else
       {
           cePickDateStart.SelectedDate = Convert.ToDateTime(txtPickDateStart.Text);
           cePickDateFinish.SelectedDate = Convert.ToDateTime(txtPickDateFinish.Text);
       }
 
Share this answer
 
Comments
rbjanaki 9-Aug-11 19:44pm    
Hi digimanus,

Thanks for your reply, however I am using windows forms in my application
Herman<T>.Instance 10-Aug-11 0:17am    
make that clear in your question!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900