Calendar Control: Exception with December 9999 Date

Discussion in 'ASP .Net Web Controls' started by Nathan Pickett, Feb 27, 2004.

  1. Hi-



    The following exception is being throw when I set the ASP.NET Calendar
    control to December 1, 9999 (end of time):



    Specified argument was out of the range of valid values. Parameter name:
    Year, Month, and Day parameters describe an unrepresentable DateTime.



    I believe that this is because when the control renders the title, the value
    for the navigation's next month is not a valid DateTime since it is greater
    than the DateTime.MaxValue (23:59:59.9999999, December 31, 9999).



    To resolve this issue I am currently using Regular Expressions to validate
    the input for the intial date. If the date is greater than December 9999 ,
    I am assigning the Calendar's TodaysDate property to November, 30 9999 in
    the Page_Load. I am also doing this check in VisibleMonthChanged event.
    This disallows the Calendar to render a view greater than November 9999.



    It would make more sense to the user if the next month navigation is disable
    or removed from the title navigation for December 9999. Is there a way to
    prevent the next month navigation element from rendering if the date is
    December 9999. Preferable without extending the Calendar control?
     
    Nathan Pickett, Feb 27, 2004
    #1
    1. Advertising

  2. Why not just trap for a datetime within the allowable range and be done with
    it?

    I wouldn't spend a lot of time on a problem that is several millenia away.

    Ken

    "Nathan Pickett" <> wrote in message
    news:OiKvpjW$...
    > Hi-
    >
    >
    >
    > The following exception is being throw when I set the ASP.NET Calendar
    > control to December 1, 9999 (end of time):
    >
    >
    >
    > Specified argument was out of the range of valid values. Parameter name:
    > Year, Month, and Day parameters describe an unrepresentable DateTime.
    >
    >
    >
    > I believe that this is because when the control renders the title, the
    > value
    > for the navigation's next month is not a valid DateTime since it is
    > greater
    > than the DateTime.MaxValue (23:59:59.9999999, December 31, 9999).
    >
    >
    >
    > To resolve this issue I am currently using Regular Expressions to validate
    > the input for the intial date. If the date is greater than December 9999
    > ,
    > I am assigning the Calendar's TodaysDate property to November, 30 9999 in
    > the Page_Load. I am also doing this check in VisibleMonthChanged event.
    > This disallows the Calendar to render a view greater than November 9999.
    >
    >
    >
    > It would make more sense to the user if the next month navigation is
    > disable
    > or removed from the title navigation for December 9999. Is there a way to
    > prevent the next month navigation element from rendering if the date is
    > December 9999. Preferable without extending the Calendar control?
    >
    >
    >
     
    Ken Cox [Microsoft MVP], Feb 28, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2ltb24=?=

    re configure data adapter (9999) not

    =?Utf-8?B?c2ltb24=?=, Jan 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    290
    =?Utf-8?B?c2ltb24=?=
    Jan 23, 2004
  2. JavaRookie
    Replies:
    4
    Views:
    1,681
    Gerbrand van Dieijen
    Oct 13, 2003
  3. Gianni
    Replies:
    6
    Views:
    809
    Dag Sunde
    Nov 5, 2004
  4. Marcio DeBarros
    Replies:
    2
    Views:
    2,340
    Marcio DeBarros
    Oct 2, 2003
  5. Nathan Pickett

    Calendar Control: Breaks if set to December 9999

    Nathan Pickett, Feb 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    108
    Nathan Pickett
    Feb 27, 2004
Loading...

Share This Page