aspnet-devexpress-dot-web-dot-aspxcalendar-fc78ad66.md
Allows you to disable the calendar’s days.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public event EventHandler<CalendarCustomDisabledDateEventArgs> CustomDisabledDate
Public Event CustomDisabledDate As EventHandler(Of CalendarCustomDisabledDateEventArgs)
The CustomDisabledDate event's data class is CalendarCustomDisabledDateEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Date | Gets the currently processed date. |
| IsDisabled | Specifies whether the processed date is disabled for selection. |
The CustomDisabledDate event is raised on the server side each time a day cell needs to be rendered within the calendar. You can use the CalendarCustomDisabledDateEventArgs.Date event argument property to determine the currently processed day. The CalendarCustomDisabledDateEventArgs.IsDisabled property allows you to specify the date avalability for the selection.
Additionally, you can use the ASPxClientCalendar.CustomDisabledDate event to disable dates on the client side. The ASPxCalendar.DisabledDates property allows you to specify a collection of dates to be disabled in a calendar control.
The CustomDisabledDate event handlers affect the manner in which the calendar is updated (navigates to another month/year).
true, the calendar initiates a postback to the server; otherwise, it’s updated using callback technology.Note that the CustomDisabledDate event works only on callbacks. If the CustomDisabledDate event is handled, place the calendar in the separate Partial View and specify the calendar’s CallbackRouteValues property.
In this code sample, the ASPxCalendar control uses the client-side ASPxClientCalendar.CustomDisabledDate and server-side ASPxCalendar.CustomDisabledDate events to disable all dates that fall on a Wednesday.
The image below shows the result.
protected void ASPxCalendar1_CustomDisabledDate(object sender, CalendarCustomDisabledDateEventArgs e) {
if(e.Date.DayOfWeek == DayOfWeek.Wednesday)
e.IsDisabled = true;
}
Protected Sub ASPxCalendar1_CustomDisabledDate(ByVal sender As Object, ByVal e As CalendarCustomDisabledDateEventArgs)
If e.Date.DayOfWeek = DayOfWeek.Wednesday Then
e.IsDisabled = True
End If
End Sub
function onCustomDisabledDate(s, e) {
if(e.date.getDay() == 3)
e.isDisabled = true;
}
<dx:ASPxCalendar ID="ASPxCalendar1" runat="server" OnCustomDisabledDate="ASPxCalendar1_CustomDisabledDate">
<ClientSideEvents CustomDisabledDate="onCustomDisabledDate" />
</dx:ASPxCalendar>
See Also