1

如何禁止在我的日历中选择过去的日期?

这是我的 asp 代码:

<td>
    <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
 </td>
4

1 回答 1

3

使用控件的DayRender事件Calendar

.aspx:

<asp:Calendar ID="Calendar1" runat="server" SelectionMode="None"     
     OnDayRender="Calendar1_DayRender" 
</asp:Calendar> 

你的事件在后面的代码中::

Protected Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs) Handles Calendar1.DayRender
    If e.Day.Date < Date.Today Then
        e.Day.IsSelectable = False
        e.Cell.ForeColor = System.Drawing.Color.Gray
    End If
End Sub
于 2013-09-04T07:27:13.537 回答