Calendar.SelectionMode Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur mode pemilihan tanggal pada Calendar kontrol yang menentukan apakah pengguna dapat memilih satu hari, seminggu, atau satu bulan penuh.
public:
property System::Web::UI::WebControls::CalendarSelectionMode SelectionMode { System::Web::UI::WebControls::CalendarSelectionMode get(); void set(System::Web::UI::WebControls::CalendarSelectionMode value); };
[System.ComponentModel.Bindable(true)]
public System.Web.UI.WebControls.CalendarSelectionMode SelectionMode { get; set; }
public System.Web.UI.WebControls.CalendarSelectionMode SelectionMode { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.SelectionMode : System.Web.UI.WebControls.CalendarSelectionMode with get, set
member this.SelectionMode : System.Web.UI.WebControls.CalendarSelectionMode with get, set
Public Property SelectionMode As CalendarSelectionMode
Nilai Properti
Salah CalendarSelectionMode satu nilai. Nilai defaultnya adalah Day.
- Atribut
Pengecualian
Mode pemilihan yang ditentukan bukan salah CalendarSelectionMode satu nilai.
Contoh
Contoh kode berikut menunjukkan cara menggunakan SelectionMode properti untuk mengizinkan pemilihan tanggal menurut satu hari, seminggu, atau satu bulan penuh.
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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>Calendar Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Calendar Example</h3>
<asp:Calendar id="calendar1" runat="server"
SelectionMode="DayWeekMonth"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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>Calendar Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Calendar Example</h3>
<asp:Calendar id="calendar1" runat="server"
SelectionMode="DayWeekMonth"/>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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" >
<script runat="server" >
void Selection_Change(Object sender, EventArgs e)
{
// Set the day selection mode.
Calendar1.SelectionMode =
(CalendarSelectionMode)ModeList.SelectedIndex;
}
</script>
<head runat="server">
<title> Calendar SelectionMode Example </title>
</head>
<body>
<form id="form1" runat="server">
<h3> Calendar SelectionMode Example </h3>
Choose the date selection mode.
<br /><br />
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br /><br />
<table cellpadding="5">
<tr>
<td>
Mode:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ModeList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> None </asp:ListItem>
<asp:ListItem Selected="True"> Day </asp:ListItem>
<asp:ListItem> DayWeek </asp:ListItem>
<asp:ListItem> DayWeekMonth </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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" >
<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
</script>
<head runat="server">
<title> Calendar SelectionMode Example </title>
</head>
<body>
<form id="form1" runat="server">
<h3> Calendar SelectionMode Example </h3>
Choose the date selection mode.
<br /><br />
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br /><br />
<table cellpadding="5">
<tr>
<td>
Mode:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ModeList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> None </asp:ListItem>
<asp:ListItem Selected="True"> Day </asp:ListItem>
<asp:ListItem> DayWeek </asp:ListItem>
<asp:ListItem> DayWeekMonth </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
Keterangan
SelectionMode Gunakan properti untuk menentukan mode pemilihan tanggal pada Calendar kontrol. Properti ini diatur dengan salah CalendarSelectionMode satu nilai enumerasi. Anda dapat menentukan apakah pengguna dapat memilih satu hari, seminggu, atau satu bulan penuh, atau Anda dapat menonaktifkan kemampuan pemilihan tanggal sepenuhnya.
Ketika properti ini diatur ke CalendarSelectionMode.DayWeek atau CalendarSelectionMode.DayWeekMonth, kolom pemilih tambahan yang berisi kontrol pemilihan minggu dan bulan ditampilkan di kolom Calendar pertama kontrol.
SelectorStyle Gunakan properti untuk menyesuaikan tampilan kolom ini.
Untuk menonaktifkan pilihan tanggal, atur properti ini ke CalendarSelectionMode.None.