I use Telerik RadCalendar ASP.NET control. How I can in code reset selected date? (Set no selected Date)
From their site:
http://demos.telerik.com/aspnet-ajax/calendar/examples/programming/clientsideapi/defaultcs.aspx
unselectDate(date); //Takes a triplet representation of a date and if valid deselects it in the calendar.
unselectDates(dates); //Takes an array of triplets representing dates and if valid deselects them in the calendar.
First you can find what dates are selected with get_selectedDates()
Then put them in the unselect method.
var selectedDates = get_selectedDates();
unselectDates(selectedDates);
If you dont know what dates are selected maybe you can reload the calendar.
If you want to clear the selection server-side then this should work:
RadCalendarObject.SelectedDates.Clear();
Related
I am writing an application which updates the date selected in RadCalender to a database column on click of a button.
After the button is clicked, i want to clear the selected date so that the end user selects a date before clicking the button again
I have tired using the below code, but it dosen't appear to work
calExpirydate.SelectedDates.Clear();
You can use the following script:
var selectedDates = get_selectedDates(); //Gets the "list" of selected dates
unselectDates(selectedDates); // unselects all dates that may have been selected.
Code taken from: Telerik Reset Calendar Selected Date
----------------------------
radCal1.RemoveFocusedDate(true); //Will remove the calendar date currently selected.
I have a datetime picker in windows form. When i am selecting a date it shows the last selected date and current date. But i want to shows only current date always. It should not show last selected date and current date(both) on the selection dropdown.
public FieldControl()
{
InitializeComponent();
dtpDate.Value = DateTime.Now;
}
Hello Kumar is right,
but what is sense of selectable date and time component where is only one option to select?
Isn't better to make datetimepicker disabled? At least it's less confusing for user and by default actual date is selected when datetimepicker is dispayed.
Jaroslav
Try this :
you can get just today's date as a DateTime using the Today property:
dtpDate.Value = DateTime.Today;
if you want to show only current date in your datepicker then use this code:
dtpDate.MinDate = dtpDate.MaxDate = DateTime.Now;
For more information
Refer this link
You can't do it on the picker. But you can fake it. Resize the dateTimePicker so it only shows the pick button. Then place it next to a textbox. In the onClose event you write the selected value to the textbox, and set the value of the dateTimePicker back to Today.
Im writing a hotel booking system with VS2012 which uses ms sql and in the booking i have two datetimepicker controls. When i select a date in the first one the date automatically gets transfered to the second datetimepicker. I now want when the user opens up the second datetimepicker not being able to select a date that is before the first date from the first datetimepicker. I dont want to use if method displaying a message i just want the dates to be "greyed" out.
Is that possible and how?
*edit (screenshot of how i would like it to be viewed or similar http://i43.tinypic.com/2zpimvs.jpg )
*edit2: its not the control(dateTimePicker2) it self i want to grey out, its the dates inside it that is smaller then the date selected in dateTimePicker1. The screenshot provided is in the area of what im looking for.
You could try this:
DateTimePicker2.MinValue = Convert.toDateTime(DateTimePicker1.SelectedDate);
EDIT
Standard controls don't support the grey-out of a datetimepicker. If you want to do this, you need to subclass the datetimepicker or look at a premade control like a DateEdit from devexpress (i think they even have free controls).
Change the second datepicker MinDate to first DatePicker selected date .. like below ..
rdpDatePicker2.MinDate = rdpDatePicker1.SelectedDate.Value;
When I display my Calendar, I select a certain date by default:
myCalendar.SelectedDate = myDateTime;
The problem is that the month that is displayed doesn't change. It stays at the current month. I searched high and low for a way to display a certain month.
How can I force the Calendar to display the month that contains the selected date?
Have you tried using the DisplayDate property? More here.
I have an ASP.NET 4 calendar display problem. I want to programmatically set the calendar. So, I put this code in the void Page_Load(object sender, EventArgs e) function:
Calendar1.SelectedDate = DateTime.Parse("2011-07-25");
it works fine. But, it displays the current month of the calendar (August) instead of the date I selected (July). I have to select back one month to see the date that I programmatically assigned.
What should i do?
Thanks!
You need to set the VisibleDate property to the month that you want it to show =)
There is a gotcha that you should be aware of.
If you set the selected date to DateTime.Now or something based on it such as DateTime.Now.AddYears(1) then the selected date will not be highlighted in the calendar even though it is selected.
You need to remove the time component using DateTime.Now.Date so that the calendar can do the comparison correctly when rendering. It took me a bit of debugging in the DayRenderEventHandler to figure that out.
I hope that somebody finds it useful.