所以我想使用CompareValidator来确保ASP Calendar对象的选定日期是将来的日期。我不知道该怎么做,但这是我到目前为止所做的。当我尝试这样做虽然它告诉我我无法验证日历对象?
.aspx代码:
<asp:CompareValidator ID="ValidateEventDate" ControlToValidate="Calendar1" Operator="GreaterThanEqual"
Type="Date" runat="server" ErrorMessage="Can't pick a date in the past">
<asp:Label ID="eventDate" ForeColor="Black" runat="server"
Text="Select a Date"></asp:Label>
<asp:Calendar ID="Calendar1" runat="server"
onselectionchanged="Calendar1_SelectionChanged" BackColor="#FF0000"></asp:Calendar>
<br />
这是我背后的代码:
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
ValidateEventDate.ValueToCompare = DateTime.Now.ToString("dd/MM/yyyy");
}
有任何想法如何实现这个?