VS2010 calendar control incorrect dates

752 Views Asked by At

The following issue is that i have 3 calendar controls (different ID) in a ASP.NET page (Framework 4.0), the calendar control is not visible but when i click a button it opens up and lets you select a date, everything is fine until i open the second calendar control when i chose a different date it sets the previous date (from calendar control 1)

Calendedar control code

Protected Sub Calendar1_AddDataControl_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar1_AddDataControl.SelectionChanged
    TextBox6_AddDataControl.Text = Calendar1_AddDataControl.SelectedDate.ToShortDateString
    Calendar1_AddDataControl.Visible = False
End Sub

Example: Control 1 Date: 01/14/2013 Control 2 Date: 01/14/2013 but i selected 02/05/2013 Control 3 Date: 01/14/2013 but i seected 02/06/2013

i did my homework trying to read previous questions, looking over the internet and i was unable to find a solution to this, i'm a newbie at coding in ASP.Net using Visual Studio 2010.

1

There are 1 best solutions below

0
On BEST ANSWER

I understand your handler methods all have the same body except the TextBox identifier. When you select a date in your Calendar2_AddDataControl, you want to use its SelectedDate value for the TextBox. The handler method for Calendar2 would look like this:

Protected Sub Calendar2_AddDataControl_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar2_AddDataControl.SelectionChanged
    // Display SelectedDate of Calendar_2_
    TextBox7_AddDataControl.Text = Calendar2_AddDataControl.SelectedDate.ToShortDateString
    Calendar2_AddDataControl.Visible = False
End Sub

assuming it's TextBox7 that should display its selected date.