SelectedDatesCollection.Contains メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As SelectedDatesCollection Dim date As DateTime Dim returnValue As Boolean returnValue = instance.Contains(date)
戻り値
指定した System.DateTime が SelectedDatesCollection に含まれている場合は true。それ以外の場合は false。


Contains メソッドを使用して、指定した System.DateTime オブジェクトが SelectedDatesCollection コレクションに含まれているかどうかを確認する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub Button_Click(sender As Object, e As EventArgs) Dim current_month As Integer = Calendar1.VisibleDate.Month Dim current_year As Integer = Calendar1.VisibleDate.Year Calendar1.VisibleDate = Calendar1.TodaysDate Dim theDate As New DateTime(current_year, current_month, 15) If Calendar1.SelectedDates.Contains(theDate) Then Label1.Text = "Yes, you selected the 15th!!" Else Label1.Text = "No, you didn't select the 15th!!" End If End Sub </script> </head> <body> <form runat="server"> <asp:Calendar ID="Calendar1" runat="server" SelectionMode="DayWeekMonth"/> <hr> Select dates on the Calendar and click the button below <br> to validate that the 15th on the month was selected <br><br> <asp:Button id="Button1" text="Validate the 15th" OnClick="Button_Click" runat=server /> <br><br> <asp:Label id="Label1" runat=server /> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void Button_Click(Object sender, EventArgs e) { int current_month = Calendar1.VisibleDate.Month; int current_year = Calendar1.VisibleDate.Year; Calendar1.VisibleDate = Calendar1.TodaysDate; DateTime date = new DateTime(current_year, current_month, 15); if (Calendar1.SelectedDates.Contains(date)) Label1.Text = "Yes, you selected the 15th!!"; else Label1.Text = "No, you didn't select the 15th!!"; } </script> </head> <body> <form runat="server"> <asp:Calendar ID="Calendar1" runat="server" SelectionMode="DayWeekMonth"/> <hr> Select dates on the Calendar and click the button below <br> to validate that the 15th on the month was selected <br><br> <asp:Button id="Button1" text="Validate the 15th" OnClick="Button_Click" runat=server /> <br><br> <asp:Label id="Label1" runat=server /> </form> </body> </html>

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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SelectedDatesCollection.Contains メソッドのページへのリンク