I have added a WebmonthCalendar to my page and set it to have
SelectionType = "Week"
Now I want to set the initial date and have set this server side using
WebMonthCalendar1.SelectedDate = DateTime.Now
I sort of expected it to select the current week - but it doesn't. If I click to select a day within the week the week itself is selected but I need to set it initially to select the current week. How do I do this?
Hello,
Is there any way to set the selected date in javascript. Something likes:
var calendar = $find("WebMonthCalendar1");
var date = calendar.set_selectedDate("some appropriate data");
I have try this. It doesn't work. Thanks for your information.
KH
Hello cmdrew ,
On the server you should specify RangeMin and RangeMax of the SelectedDates collection:
protected void Page_Load(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
DateTime startDate = DateTimeHelper.StartOfWeek(dt, DayOfWeek.Monday);
DateTime endDate = DateTimeHelper.EndOfWeek(dt, DayOfWeek.Sunday);
WebMonthCalendar1.SelectedDates.RangeMin = startDate;
WebMonthCalendar1.SelectedDates.RangeMax = endDate;
}
public static class DateTimeHelper
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
int diff = dt.DayOfWeek - startOfWeek;
if (diff < 0)
diff += 7;
return dt.AddDays(-1 * diff).Date;
public static DateTime EndOfWeek(this DateTime dt, DayOfWeek endOfWeek)
int diff = endOfWeek - dt.DayOfWeek;
return dt.AddDays(diff).Date;
Please let me know if you need further assistance regarding this