Calendar.HasWeekSelectors(CalendarSelectionMode) Method

Definition

Determines whether a CalendarSelectionMode object contains week selectors.

protected bool HasWeekSelectors (System.Web.UI.WebControls.CalendarSelectionMode selectionMode);

Parameters

selectionMode
CalendarSelectionMode

One of the CalendarSelectionMode values.

Returns

true if the CalendarSelectionMode contains week selectors; otherwise, false.

Examples

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"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom Calendar - HasWeekSelectors - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom Calendar - HasWeekSelectors - C# Example</h3>

      <aspSample:CustomCalendarHasWeekSelectors
        id="Calendar1"
        runat="server" />

    </form>
  </body>
</html>
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.
      base.OnPreRender(e);
    }
  }
}

Remarks

The CalendarSelectionMode values DayWeek and DayWeekMonth both contain week selectors.

Applies to

Produk Versi
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1