简体   繁体   中英

Calendar Validation in asp.net using vb.net

how can i forbid past date to be chosen in my calendar?

this is my asp code:

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

Use the DayRender event of the Calendar control.

.aspx:

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

And your event in code behind::

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM