menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class CalendarBase<T> - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class CalendarBase<T>

    Represents a calendar component that displays a Gregorian calendar and allows users to select dates with full support for localization, min/max constraints, and custom behaviors.

    Inheritance
    System.Object
    SfBaseComponent
    SfInputTextBase<T>
    CalendarBase<T>
    SfCalendar<TValue>
    SfDatePicker<TValue>
    SfDateRangePicker<TValue>
    Inherited Members
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.GetEffectivePlatform()
    SfBaseComponent.GetMainComponentPlatform()
    SfBaseComponent.IsMainLicenseComponent()
    SfBaseComponent.LicenseContext
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    SfBaseComponent.ValidateLicense()
    SfInputTextBase<T>._value
    SfInputTextBase<T>.APPEND
    SfInputTextBase<T>.APPEND_ICON
    SfInputTextBase<T>.ARIA_DISABLED
    SfInputTextBase<T>.BaseAutocomplete
    SfInputTextBase<T>.BaseFloatLabelType
    SfInputTextBase<T>.BaseHtmlAttributes
    SfInputTextBase<T>.BaseInputAttributes
    SfInputTextBase<T>.BaseIsReadOnlyInput
    SfInputTextBase<T>.BasePlaceholder
    SfInputTextBase<T>.BaseReadonly
    SfInputTextBase<T>.BaseShowClearButton
    SfInputTextBase<T>.BaseTabIndex
    SfInputTextBase<T>.BaseWidth
    SfInputTextBase<T>.ChangeHandler(ChangeEventArgs)
    SfInputTextBase<T>.CLEAR_ICON_HIDE
    SfInputTextBase<T>.ClearElement
    SfInputTextBase<T>.CLEARICONHIDE
    SfInputTextBase<T>.ComponentReference
    SfInputTextBase<T>.ContainerAttr
    SfInputTextBase<T>.containerAttributes
    SfInputTextBase<T>.CONTROL_CONTAINER
    SfInputTextBase<T>.CONTROL_OLD_CONTAINER
    SfInputTextBase<T>.CssClass
    SfInputTextBase<T>.DataId
    SfInputTextBase<T>.DECREMENT
    SfInputTextBase<T>.DECREMENT_TITLE
    SfInputTextBase<T>.DecrementTitle
    SfInputTextBase<T>.DISABLE
    SfInputTextBase<T>.DISABLE_ICON
    SfInputTextBase<T>.DISABLED_ATTR
    SfInputTextBase<T>.Enabled
    SfInputTextBase<T>.EnablePersistence
    SfInputTextBase<T>.EnableRtl
    SfInputTextBase<T>.FLOATINPUT
    SfInputTextBase<T>.FloatLabel
    SfInputTextBase<T>.FLOATLABELBOTTOM
    SfInputTextBase<T>.FLOATLABELTOP
    SfInputTextBase<T>.FLOATTEXT
    SfInputTextBase<T>.FocusHandler(FocusEventArgs)
    SfInputTextBase<T>.FocusOutHandler(FocusEventArgs)
    SfInputTextBase<T>.FormatValue(String)
    SfInputTextBase<T>.FormatValueAsString(T)
    SfInputTextBase<T>.GROUP_ICON
    SfInputTextBase<T>.ID
    SfInputTextBase<T>.INCREMENT
    SfInputTextBase<T>.INCREMENT_TITLE
    SfInputTextBase<T>.IncrementTitle
    SfInputTextBase<T>.INPUT
    SfInputTextBase<T>.inputAttr
    SfInputTextBase<T>.InputEditContext
    SfInputTextBase<T>.INPUTFOCUS
    SfInputTextBase<T>.INPUTGROUP
    SfInputTextBase<T>.InputHandler(ChangeEventArgs)
    SfInputTextBase<T>.IsClearButtonClicked
    SfInputTextBase<T>.IsFocused
    SfInputTextBase<T>.ListOfButtons
    SfInputTextBase<T>.MULTILINE
    SfInputTextBase<T>.MultilineInput
    SfInputTextBase<T>.OnAfterRenderAsync(Boolean)
    SfInputTextBase<T>.OnChangeHandler(ChangeEventArgs)
    SfInputTextBase<T>.OnInitializedAsync()
    SfInputTextBase<T>.OnInputHandler(ChangeEventArgs)
    SfInputTextBase<T>.OnParametersSetAsync()
    SfInputTextBase<T>.OnPasteHandler(ClipboardEventArgs)
    SfInputTextBase<T>.PREPEND
    SfInputTextBase<T>.PREPEND_ICON
    SfInputTextBase<T>.SetEnabled()
    SfInputTextBase<T>.SPACE
    SfInputTextBase<T>.SPIN_DOWN
    SfInputTextBase<T>.SPIN_UP
    SfInputTextBase<T>.ValidateOnInput
    SfInputTextBase<T>.Value
    SfInputTextBase<T>.ValueChanged
    SfInputTextBase<T>.WireClearBtnEvents()
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.BlurHandler(System.String, System.Boolean)
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.ClickStopPropagation
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.ContainerClass
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.IsValueTemplate
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.MouseDowSpinnerPrevent
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.MousePreventContainer
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.OnBlur
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.OnChange
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.OnFocus
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.OnInput
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.OnPaste
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.PreventIconHandler
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.RootClass
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.SpinButton
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.ValueExpression
    Syncfusion.Blazor.Inputs.SfInputTextBase<T>.ValueTemplate
    Namespace: Syncfusion.Blazor.Calendars
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class CalendarBase<T> : SfInputTextBase<T>
    Type Parameters
    Name Description
    T

    Specifies the supported value type for the calendar's selected date (e.g., DateTime, DateOnly, DateTimeOffset).

    Remarks

    The CalendarBase<T> class is the base for Syncfusion Blazor Calendar control. It enables date selection, localization, keyboard navigation, and advanced features such as restricted selection by min/max dates and multiple calendar views. It supports conversion between Gregorian and Hijri calendars. Customization for keyboard shortcuts and rendering can be achieved through exposed events and parameters.

    Examples

    The following example demonstrates how to instantiate the CalendarBase component allowing selection between a date range:

    <SfCalendar Min="@new DateTime(2020, 1, 1)" Max="@new DateTime(2025, 12, 31)" FirstDayOfWeek="1" DayHeaderFormat="DayHeaderFormats.Wide"/>

    Constructors

    CalendarBase()

    Declaration
    public CalendarBase()

    Properties

    CalendarEditContext

    Gets or sets the Microsoft.AspNetCore.Components.Forms.EditContext for the Calendar.

    Declaration
    protected EditContext CalendarEditContext { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.Forms.EditContext

    The Microsoft.AspNetCore.Components.Forms.EditContext instance that manages the editing state of the calendar's associated form.

    Remarks

    When set, this enables integration of the calendar with Blazor form validation and editing workflows.

    CalendarMode

    Gets or sets the calendar system type, such as Gregorian or Hijri.

    Declaration
    public CalendarType CalendarMode { get; set; }
    Property Value
    Type Description
    CalendarType

    A CalendarType enum value specifying the calendar system to be used in the component (e.g., Gregorian, Hijri).

    Remarks

    Use this property to enable the selection and display of dates in different calendar systems.

    Examples

    Display the calendar using the Hijri system:

    <SfCalendar CalendarMode="CalendarType.Hijri" />

    DayHeaderFormat

    Gets or sets the display format for day names shown in the calendar's header.

    Declaration
    public DayHeaderFormats DayHeaderFormat { get; set; }
    Property Value
    Type Description
    DayHeaderFormats

    A DayHeaderFormats value specifying the header day name format (Short, Narrow, Abbreviated, Wide). Default is Short.

    Remarks

    This property configures the format of day names in the calendar header row, allowing customization of the day label presentation for various cultures or UI requirements.

    Examples

    Show abbreviated day names (e.g., Mon, Tue, Wed):

    <SfCalendar DayHeaderFormat="DayHeaderFormats.Abbreviated" />

    Depth

    Gets or sets the maximum navigation depth in the calendar (e.g., Month, Year, Decade).

    Declaration
    public CalendarView Depth { get; set; }
    Property Value
    Type Description
    CalendarView

    A CalendarView value specifying the maximum depth users can navigate. Typical values are Month, Year, or Decade.

    Remarks

    The Depth must be smaller than Start to properly restrict view navigation.

    Examples

    Allow users to navigate up to the Year view only:

    <SfCalendar Start="CalendarView.Month" Depth="CalendarView.Year" />

    FirstDayOfWeek

    Gets or sets the first day of the week in the calendar view.

    Declaration
    public int FirstDayOfWeek { get; set; }
    Property Value
    Type Description
    System.Int32

    An int value representing the first day of the week, where 0 = Sunday, 1 = Monday, etc. Default is based on the current culture.

    Remarks

    Use this property to change the calendar's week layout to start on a different day (for example, Monday instead of Sunday).

    Examples

    Set the calendar's first day of the week to Monday:

    <SfCalendar FirstDayOfWeek="1" />

    KeyConfigs

    Gets or sets the custom keyboard actions for the calendar component.

    Declaration
    public Dictionary<string, object> KeyConfigs { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.Dictionary<System.String, System.Object>

    A System.Collections.Generic.Dictionary<, > that maps key action names to custom shortcut values.

    Remarks

    Use this property to provide keyboard accessibility and localization, such as customizing shortcuts for different keyboard layouts.

    Examples

    Provide custom key actions for German keyboards:

    <SfCalendar KeyConfigs="@myKeyConfigs" />
    @code {
      Dictionary<string, object> myKeyConfigs = new() { { "moveRight", "Alt+RightArrow" } };
    }

    Max

    Gets or sets the maximum selectable date for the calendar.

    Declaration
    public virtual DateTime Max { get; set; }
    Property Value
    Type Description
    System.DateTime

    A DateTime value specifying the latest date a user can select. The default is 31-Dec-2099.

    Remarks

    Use this property to restrict user selection to dates before or equal to the specified maximum.

    Examples

    Set the maximum date to 31-Dec-2025:

    <SfCalendar Max="@new DateTime(2025,12,31)" />

    Min

    Gets or sets the minimum selectable date for the calendar.

    Declaration
    public virtual DateTime Min { get; set; }
    Property Value
    Type Description
    System.DateTime

    A DateTime value specifying the earliest date a user can select. The default is 01-Jan-1900.

    Remarks

    Use this property to restrict user selection to dates on or after the specified minimum.

    Examples

    Set the minimum date to 1-Jan-2000:

    <SfCalendar Min="@new DateTime(2000,1,1)" />

    ServerTimezoneOffset

    Gets or sets the offset (in minutes) between the client and server time zones for date values.
    This property is obsolete and is no longer supported.

    Declaration
    public double ServerTimezoneOffset { get; set; }
    Property Value
    Type Description
    System.Double

    A double value representing the server timezone offset in minutes.

    Remarks

    Deprecated: Syncfusion Blazor calendar components now use client-side date processing by default. Do not rely on this property for new applications.

    ShowTodayButton

    Gets or sets a value that determines whether the today button is displayed in the calendar UI.

    Declaration
    public bool ShowTodayButton { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to show the today button; otherwise, false. Default is true.

    Remarks

    The today button allows users to quickly select the current date in the calendar.

    Examples

    Hide the today button:

    <SfCalendar ShowTodayButton="false" />

    Start

    Gets or sets the initial calendar view displayed when the calendar is opened.

    Declaration
    public CalendarView Start { get; set; }
    Property Value
    Type Description
    CalendarView

    A CalendarView value determining whether the initial view starts from Month, Year, or Decade. Default is Month.

    Remarks

    Use this property to control which navigation level users see first when they open the calendar.

    Examples

    Set the calendar to open on the year view:

    <SfCalendar Start="CalendarView.Year" />

    WeekNumber

    Gets or sets a value indicating whether the calendar displays the week number in the UI.

    Declaration
    public bool WeekNumber { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to display the week number; otherwise, false.

    Remarks

    When enabled, a week number column is shown for each date row in the calendar.

    WeekRule

    Gets or sets the rule used to determine the first week of the year in the calendar.

    Declaration
    public CalendarWeekRule WeekRule { get; set; }
    Property Value
    Type Description
    System.Globalization.CalendarWeekRule

    A System.Globalization.CalendarWeekRule value that specifies how the first week of the year is calculated.

    Remarks

    The default is culture-dependent. Valid options include FirstDay, FirstFullWeek, and FirstFourDayWeek.

    Examples

    Specify the calendar week rule:

    <SfCalendar WeekRule="CalendarWeekRule.FirstFourDayWeek" />

    Methods

    ChangeEvent(EventArgs, Boolean)

    Triggers when the value get changed.

    Declaration
    protected virtual void ChangeEvent(EventArgs args, bool isSelection = false)
    Parameters
    Type Name Description
    System.EventArgs args

    Specifies the System.EventArgs.

    System.Boolean isSelection

    Determines whether selection is made using the mouse or keyboard.

    ConvertDateValue(T)

    Declaration
    protected DateTime ConvertDateValue(T dateValue)
    Parameters
    Type Name Description
    T dateValue
    Returns
    Type
    System.DateTime

    ConvertToGregorian(String, String)

    Converts a formatted Hijri date string to a Gregorian System.DateTime object.

    Declaration
    public T ConvertToGregorian(string hijriDate, string format)
    Parameters
    Type Name Description
    System.String hijriDate

    The Hijri date string to convert, formatted according to the specified format.

    System.String format

    The format string that specifies the structure of the hijriDate. Valid format components include "dd" for day, "MM" for month (numeric), "MMM"/"MMMM" for month name, "yyyy" for year, and "HH"/"mm"/"ss" for time.

    Returns
    Type Description
    T

    A System.DateTime object in Gregorian format representing the date and time specified in the Hijri hijriDate.

    Remarks

    This method splits the hijriDate and format into individual components, parses each component to extract day, month, year, and time values, and converts them from Hijri to Gregorian. It assumes that the hijriDate is in the Hijri calendar.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when hijriDate or format is null or empty.

    ConvertToHijri(T, String)

    Converts a Gregorian System.DateTime object to a formatted Hijri date string.

    Declaration
    public string ConvertToHijri(T gregorianDate, string format)
    Parameters
    Type Name Description
    T gregorianDate

    The Gregorian date to be converted to Hijri, of type T.

    System.String format

    The format string specifying the output structure of the Hijri date. Supports standard date format specifiers such as "dd", "MM", "MMM", "MMMM", "yyyy", and time components.

    Returns
    Type Description
    System.String

    A string representing the Hijri date formatted according to the specified format.

    Remarks

    This method converts a System.DateTime value from Gregorian to Hijri and formats it. If the format string contains "MMM" or "MMMM", it replaces the month part with a Hijri month name (abbreviated or full, depending on the format).

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when format is null.

    GetDefaultFormat()

    Declaration
    protected string GetDefaultFormat()
    Returns
    Type
    System.String

    GetHijriMonthIndex(String, String)

    Declaration
    protected int GetHijriMonthIndex(string monthName, string format)
    Parameters
    Type Name Description
    System.String monthName
    System.String format
    Returns
    Type
    System.Int32

    ReplaceMonthName(String, DateTime, String[], String)

    Declaration
    protected static string ReplaceMonthName(string formattedDate, DateTime finalDate, string[] hijriMonths, string format)
    Parameters
    Type Name Description
    System.String formattedDate
    System.DateTime finalDate
    System.String[] hijriMonths
    System.String format
    Returns
    Type
    System.String
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved