YouTip LogoYouTip

Prop Webcontrol Calendar Shownextprevmonth

## ASP.NET Calendar ShowNextPrevMonth Property The `ShowNextPrevMonth` property is a member of the ASP.NET WebControl `Calendar` class. It controls whether the navigation links for the next and previous months are displayed in the title header of the Calendar control. --- ## Definition and Usage By default, the `ShowNextPrevMonth` property is set to `true`, which displays the navigation arrows or text (such as `<` and `>`) allowing users to navigate to the next or previous month. Setting this property to `false` hides these navigation links, restricting the user to viewing only the currently selected month unless navigation is handled programmatically in the code-behind. --- ## Syntax ```xml ``` ### Property Values | Value | Description | | :--- | :--- | | `true` | **Default.** Displays the next and previous month navigation links in the title header. | | `false` | Hides the next and previous month navigation links. | --- ## Code Examples ### Example 1: Disabling Next/Previous Month Navigation (Declarative Markup) The following example demonstrates how to set the `ShowNextPrevMonth` property to `false` in your `.aspx` markup to prevent users from navigating to other months. ```xml <%@ Page Language="C#" %> ASP.NET Calendar ShowNextPrevMonth Example

Calendar with Navigation Disabled

``` ### Example 2: Programmatically Toggling Navigation (C# Code-Behind) You can also control this property dynamically in your code-behind file based on user roles or specific application states. ```csharp // Disable next/prev month navigation programmatically protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Hide navigation links cal1.ShowNextPrevMonth = false; } } ``` --- ## Considerations and Best Practices 1. **User Experience (UX):** Disabling next/previous navigation is highly useful when you want to restrict users to selecting dates within the current month only (e.g., for monthly reporting, scheduling within a fixed sprint, or booking systems with strict date boundaries). 2. **Styling Navigation Links:** If `ShowNextPrevMonth` is set to `true`, you can further customize the appearance of the navigation links using properties like `NextPrevStyle`, `NextMonthText`, and `PrevMonthText`. 3. **Title Format Dependency:** The navigation links are rendered inside the calendar's title section. Therefore, the `ShowHeader` property must be set to `true` (which is its default value) for the `ShowNextPrevMonth` property to have any visible effect.
← Prop Webcontrol Calendar ShowtProp Webcontrol Calendar Showg β†’