YouTip LogoYouTip

Prop Webcontrol Calendar Firstdayofweek

## ASP.NET Calendar FirstDayOfWeek Property The `FirstDayOfWeek` property is a member of the ASP.NET WebControl `Calendar` class. It is used to specify which day of the week is displayed in the first column of the calendar control. --- ## Definition and Usage By default, the first day of the week displayed in the `Calendar` control is determined by the application's current culture settings (typically Sunday in the United States, or Monday in many European regions). By using the `FirstDayOfWeek` property, you can manually override this default behavior and force the calendar to start on any specific day of the week (e.g., Monday, Wednesday, or Saturday) to match your application's layout or regional requirements. --- ## Syntax ```xml ``` ### Property Values The `FirstDayOfWeek` property accepts values defined by the `FirstDayOfWeek` enumeration. The available options are: | Value | Description | | :--- | :--- | | `Default` | The first day of the week is determined by the system's local culture settings. | | `Monday` | Sets Monday as the first day of the week. | | `Tuesday` | Sets Tuesday as the first day of the week. | | `Wednesday` | Sets Wednesday as the first day of the week. | | `Thursday` | Sets Thursday as the first day of the week. | | `Friday` | Sets Friday as the first day of the week. | | `Saturday` | Sets Saturday as the first day of the week. | | `Sunday` | Sets Sunday as the first day of the week. | --- ## Code Examples ### Declarative Syntax (ASPX) The following example demonstrates how to explicitly set the first day of the week to **Wednesday** using declarative markup: ```xml <%@ Page Language="C#" %> Calendar FirstDayOfWeek Example

Setting FirstDayOfWeek to Wednesday

``` ### Programmatic Approach (C#) You can also set this property dynamically in your code-behind file (e.g., during the `Page_Load` event): ```csharp protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Programmatically set the first day of the week to Monday cal1.FirstDayOfWeek = FirstDayOfWeek.Monday; } } ``` --- ## Considerations and Best Practices 1. **Localization & Globalization:** If your application supports multiple languages and regions, it is generally recommended to keep `FirstDayOfWeek` set to `Default`. This ensures that the calendar automatically adapts to the user's preferred regional settings. 2. **Visual Layout:** Changing the first day of the week shifts all dates in the calendar grid. Ensure that your header style (`DayHeaderStyle`) is clearly visible so users can easily identify which column represents which day.
← Prop Webcontrol Calendar NextmProp Webcontrol Calendar Dayst β†’