Unable to set date in calender

2 posts, 0 answers
  1. Saran kumar
    Saran kumar avatar
    58 posts
    Member since:
    Sep 2009

    Posted 31 Aug 2010 Link to this post

    hi im using a radcalender as mentioned below.
    <telerik:RadDatePicker ID="radPublishDate" runat="server" Style="margin-left: 0px;
                                                        z-index: 11000000000000;" ClientEvents-OnPopupOpening="PopupOpening" Height="12px"
                                                        Width="100px" Culture="English (United States)" Skin="Office2007" EnableMultiSelect="false">
                                                        <DateInput ID="publishDateInput" runat="server" Height="14px" DateFormat="MM/dd/yyyy"
                                                        <Calendar ID="Calendar1" Skin="Office2007" UseColumnHeadersAsSelectors="False" runat="server"
                                                            UseRowHeadersAsSelectors="False" ViewSelectorText="x" ToolTip="Select Date" ShowRowHeaders="false">
                                                        <DatePopupButton HoverImageUrl="" ImageUrl="" />

    on page load im seting the mindate as sysdate to the calender.

    radPublishDate.MinDate = DateTime.Now,
    it is all works fine, but when the databinding happends, a date less than the sysdate when i try to assign as the selected date it throws an error.

    If Not IsDBNull(dtNotesInfo.Rows(0).Item(2)) Then
                            radPublishDate.SelectedDate = CType(dtNotesInfo.Rows(0).Item(2), DateTime) 'Confidential date
                        End If
    but my requirement is, i should allow user to select date only greater than sysdate, that's i made min date at page load. but i also show the date selected by user on edititng even thought the date is less than sysdate. i struck with this please help me.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 31 Aug 2010 Link to this post

    Hello Saran,

    One suggestion is setting the MinDate only when opening the calendar pop-up, from client side. Check out the sample code below.

    <telerik:RadDatePicker ID="radPublishDate" runat="server"
        <ClientEvents OnPopupOpening="PopupOpening" />

    Java Script:
    <script type="text/javascript">
        function PopupOpening(sender, args) {
         var datePicker = sender;
         var date1 = new Date();
         var my_date = date1.getDate();
         var my_month = date1.getMonth();
         var my_year = date1.getYear();
         date1 = new Date(my_year, my_date, my_month);

Back to Top