This is a migrated thread and some comments may be shown as answers.

Unable to set date in calender

1 Answer 47 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Saran kumar
Top achievements
Rank 1
Saran kumar asked on 31 Aug 2010, 06:42 AM
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"
                                                        DisplayDateFormat="MM/dd/yyyy">
                                                    </DateInput>
                                                    <Calendar ID="Calendar1" Skin="Office2007" UseColumnHeadersAsSelectors="False" runat="server"
                                                        UseRowHeadersAsSelectors="False" ViewSelectorText="x" ToolTip="Select Date" ShowRowHeaders="false">
                                                    </Calendar>
                                                    <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                                </telerik:RadDatePicker>

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.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Aug 2010, 11:21 AM
Hello Saran,

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

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

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);
     datePicker.set_minDate(date1);
     }
</script>

Thanks,
Princy.
Tags
Calendar
Asked by
Saran kumar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or