search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Adding Holidays on for ASP.NET tutorial

Asked by Anonymous
5 months ago.

can anyone tell me how to set holidays in this tutorial ?

Angular: How To Build Annual Leave Scheduling Application (ASP.NET Core Backend) | DayPilot Code

This function below sets the Weekends but i’m wondering how to set the holidays in the sameway ?

protected void DayPilotScheduler1_BeforeCellRender(object sender, DayPilot.Web.Ui.Events.BeforeCellRenderEventArgs e)
{
    if (e.IsBusiness)
    {
        e.BackgroundColor = "#ffffff";
    }
    else
    {
        e.BackgroundColor = "#f8f8f8";
    }
}
Answer posted by Dan Letecky [DayPilot]
5 months ago.

In ASP.NET WebForms, you can indeed use the BeforeCellRender event.

You just need to check whether the current cell falls on one of the defined holidays.

Example:

// Define an array of holidays
private static readonly DateTime[] Holidays = new DateTime[]
{
    new DateTime(2024, 12, 25), // Christmas
    new DateTime(2024, 1, 1),   // New Year's Day
    new DateTime(2024, 7, 4),   // Independence Day
    // Add more holidays as needed
};

protected void DayPilotScheduler1_BeforeCellRender(object sender, DayPilot.Web.Ui.Events.BeforeCellRenderEventArgs e)
{
    if (Holidays.Contains(e.Start.Date))
    {
        e.BackgroundColor = "#f8f8f8"; // Example color for holidays
    }
}
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.