SelectedDatesCollection.Contains-Methode
Gibt einen Wert zurück, der angibt, ob die SelectedDatesCollection-Auflistung das angegebene System.DateTime-Objekt enthält.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Public Function Contains ( _
date As DateTime _
) As Boolean
'Usage
Dim instance As SelectedDatesCollection
Dim date As DateTime
Dim returnValue As Boolean
returnValue = instance.Contains(date)
public bool Contains (
DateTime date
)
public:
bool Contains (
DateTime date
)
public boolean Contains (
DateTime date
)
public function Contains (
date : DateTime
) : boolean
Parameter
- date
Die System.DateTime, die in SelectedDatesCollection gesucht werden soll.
Rückgabewert
true, wenn SelectedDatesCollection die angegebene System.DateTime enthält, andernfalls false.
Hinweise
Mit dieser Methode können Sie bestimmen, ob die SelectedDatesCollection-Auflistung das angegebene System.DateTime-Objekt enthält.
Beispiel
Im folgenden Codebeispiel wird die Verwendung der Contains-Methode veranschaulicht, um zu bestimmen, ob die SelectedDatesCollection-Auflistung das angegebene System.DateTime-Objekt enthält.
<%@ 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>
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
SelectedDatesCollection-Klasse
SelectedDatesCollection-Member
System.Web.UI.WebControls-Namespace
System.DateTime
Calendar.SelectedDates-Eigenschaft
Calendar-Klasse