Export (0) Print
Expand All

Calendar.HasWeekSelectors Method

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Determines whether a CalendarSelectionMode object contains week selectors.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

protected bool HasWeekSelectors(
	CalendarSelectionMode selectionMode


Type: System.Web.UI.WebControls.CalendarSelectionMode

One of the CalendarSelectionMode values.

Return Value

Type: System.Boolean
true if the CalendarSelectionMode contains week selectors; otherwise, false.

The CalendarSelectionMode values DayWeek and DayWeekMonth both contain week selectors.

The following code example demonstrates how to determine the value of the HasWeekSelectors property in a custom Calendar control.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
    <title>Custom Calendar - HasWeekSelectors - C# Example</title>
    <form id="Form1" method="post" runat="server">
      <h3>Custom Calendar - HasWeekSelectors - C# Example</h3>

        runat="server" />

using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class CustomCalendarHasWeekSelectors : System.Web.UI.WebControls.Calendar
    protected override void OnPreRender(System.EventArgs e)
      // Determine if a CalendarSelectionMode.DayWeek contains WeekSelectors. 
      bool hasWeekSelectors = this.HasWeekSelectors(System.Web.UI.WebControls.CalendarSelectionMode.DayWeek);

      // Call the base's OnPreRender method. 

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft