Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Date Time Picker (I searched already)

Date Time Picker (I searched already)

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-netcom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aqzman_
    wrote on last edited by
    #1

    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

    F 1 Reply Last reply
    0
    • A 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

      F Offline
      F Offline
      Fred_Smith
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • F Fred_Smith

        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

        A Offline
        A Offline
        aqzman_
        wrote on last edited by
        #3

        That's great! Thanks a lot for your reply, and help!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups