Export (0) Print
Expand All
0 out of 4 rated this helpful - Rate this topic

Calendar.SelectionMode Property

Gets or sets the date selection mode on the Calendar control that specifies whether the user can select a single day, a week, or an entire month.

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

Public Property SelectionMode As CalendarSelectionMode
Dim instance As Calendar
Dim value As CalendarSelectionMode

value = instance.SelectionMode

instance.SelectionMode = value
/** @property */
public CalendarSelectionMode get_SelectionMode ()

/** @property */
public void set_SelectionMode (CalendarSelectionMode value)

public function get SelectionMode () : CalendarSelectionMode

public function set SelectionMode (value : CalendarSelectionMode)

Property Value

One of the CalendarSelectionMode values. The default value is Day.
Exception typeCondition


The specified selection mode is not one of the CalendarSelectionMode values.

Use the SelectionMode property to specify the date selection mode on the Calendar control. This property is set with one of the CalendarSelectionMode enumeration values. You can specify whether the user can select a single day, a week, or an entire month, or you can disable date-selection capability entirely.

When this property is set to CalendarSelectionMode.DayWeek or CalendarSelectionMode.DayWeekMonth, an additional selector column that contains week and month selection controls is displayed in the first column of the Calendar control. Use the SelectorStyle property to customize the appearance of this column.

To disable date selection, set this property to CalendarSelectionMode.None.

The following code example demonstrates how to use the SelectionMode property to allow date selection by a single day, a week, or an entire month.

<%@ Page Language="VB" AutoEventWireup="True" %>


   <form runat="server">

      <h3>Calendar Example</h3>

      <asp:Calendar id="calendar1" runat="server"


<%@ Page Language="VB" AutoEventWireup="True" %>

   <script runat="server" >
      Sub Selection_Change(sender As Object, e As EventArgs)

         ' Set the day selection mode.
         Calendar1.SelectionMode = _
            CType(ModeList.SelectedIndex, CalendarSelectionMode)

      End Sub

   <form runat="server">
      <h3> Calendar SelectionMode Example </h3>

      Choose the date selection mode.

      <asp:Calendar id="Calendar1"


      <table cellpadding="5">








               <asp:DropDownList id="ModeList"

                  <asp:ListItem> None </asp:ListItem>
                  <asp:ListItem Selected="True"> Day </asp:ListItem>
                  <asp:ListItem> DayWeek </asp:ListItem>
                  <asp:ListItem> DayWeekMonth </asp:ListItem>





Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.