Date Time Picker (I searched already)
-
Hey guys, I was wondering if anyone would be able to give me a good guide, or even some tips on a good date/time picker for ASP.NET 2.0. Right now I have text boxes which are pretty simple (and annoying) to enter data into. All it is is "YYYY/MM/DD" with a lock on the characters to 10 and "HH:MM AM" for the time. They are pretty simple and don't really protect against any type of misentry. I was thinking of having three drop down list boxes for the date (Year, Month, Day) and three more for the time (Hour, Minute, AM/PM). I can only really think of one problem with that, which is if someone mistakingly picks Feburary 31st, etc. The data from these fields would be going into a SQL database, so I'd like to try to prevent all possible errors on the user side of things. The best I've come across from Googling was this http://www.codeproject.com/useritems/DateAndTimePicker.asp If anyone can recommend this, or anything else that'd be great. EDIT: I forgot to mention, I'm programming is VB.NET, if that matters. Thanks, aqzman
-
Hey guys, I was wondering if anyone would be able to give me a good guide, or even some tips on a good date/time picker for ASP.NET 2.0. Right now I have text boxes which are pretty simple (and annoying) to enter data into. All it is is "YYYY/MM/DD" with a lock on the characters to 10 and "HH:MM AM" for the time. They are pretty simple and don't really protect against any type of misentry. I was thinking of having three drop down list boxes for the date (Year, Month, Day) and three more for the time (Hour, Minute, AM/PM). I can only really think of one problem with that, which is if someone mistakingly picks Feburary 31st, etc. The data from these fields would be going into a SQL database, so I'd like to try to prevent all possible errors on the user side of things. The best I've come across from Googling was this http://www.codeproject.com/useritems/DateAndTimePicker.asp If anyone can recommend this, or anything else that'd be great. EDIT: I forgot to mention, I'm programming is VB.NET, if that matters. Thanks, aqzman
Three dropdowns: - Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec - some javascript funcitons: function daysInMonth(x,ty) { if (x==3 || x==5 || x==8 || x==10) { return 30; } else if (x==1) { if ((ty % 4 == 0) && !(ty % 100 == 0)) { return 29; } else { return 28; } } else { return 31; } } function setday() { var list1 = document.getElementById("lstYear"); var list2 = document.getElementById("lstMonth"); var list3 = document.getElementById("lstDay"); var yy = list1.selectedIndex + 2000; var cd = list3.selectedIndex + 1; // because selectedIndex is from 0 to (up to) 30 var NumberOfDays; var n; NumberOfDays = daysInMonth(list2.selectedIndex, yy); list3.options.length=0; for (n=0;n NumberOfDays || cd == 0) { list3.options[dt-1].selected = true; } else { list3.options[cd-1].selected = true; } } function leapYear() { var list2 = document.getElementById("lstMonth"); if (list2.selectedIndex == 1) {setday();} } and some code-behind to intialise the boxes (call in Page_load under an If Not Page.IsPostback then...: (NB this example initialises them to "yesterday" - set yd = Now for "today") Private Sub InitDropdowns() Dim y As Integer, li As ListItem Dim yd As Date = DateAdd(DateInterval.Day, -1, Now) For y = 2000 To Year(Now) li = New ListItem li.Value = y.ToString li.Text = y.ToString lstYear.Items.Add(li) li = Nothing Next For y = 1 To DaysInMonth(Month(yd), Year(yd)) li = New ListItem li.Value = y.ToString li.Text = y.ToString
-
Three dropdowns: - Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec - some javascript funcitons: function daysInMonth(x,ty) { if (x==3 || x==5 || x==8 || x==10) { return 30; } else if (x==1) { if ((ty % 4 == 0) && !(ty % 100 == 0)) { return 29; } else { return 28; } } else { return 31; } } function setday() { var list1 = document.getElementById("lstYear"); var list2 = document.getElementById("lstMonth"); var list3 = document.getElementById("lstDay"); var yy = list1.selectedIndex + 2000; var cd = list3.selectedIndex + 1; // because selectedIndex is from 0 to (up to) 30 var NumberOfDays; var n; NumberOfDays = daysInMonth(list2.selectedIndex, yy); list3.options.length=0; for (n=0;n NumberOfDays || cd == 0) { list3.options[dt-1].selected = true; } else { list3.options[cd-1].selected = true; } } function leapYear() { var list2 = document.getElementById("lstMonth"); if (list2.selectedIndex == 1) {setday();} } and some code-behind to intialise the boxes (call in Page_load under an If Not Page.IsPostback then...: (NB this example initialises them to "yesterday" - set yd = Now for "today") Private Sub InitDropdowns() Dim y As Integer, li As ListItem Dim yd As Date = DateAdd(DateInterval.Day, -1, Now) For y = 2000 To Year(Now) li = New ListItem li.Value = y.ToString li.Text = y.ToString lstYear.Items.Add(li) li = Nothing Next For y = 1 To DaysInMonth(Month(yd), Year(yd)) li = New ListItem li.Value = y.ToString li.Text = y.ToString