I'm currently creating an auction website using asp and vb.net. I want to manipulate the calendar s开发者_运维技巧o that only dates after the current date are selectable. How can I go about this? Thanks
You'll have to do it manually, I think. If the user selects an earlier date (you can gauge this with the "Changed" event), you can restore it to the current date and give an error message.
For example (in regular VB.NET)
Private Sub DateTimePicker1_ValueChanged(sender As System.Object, e As System.EventArgs) Handles DateTimePicker1.ValueChanged
If DateTimePicker1.Value < Now Then
DateTimePicker1.Value = Now
MsgBox("Error!")
End If
End Sub
Or, more directly, using the MinDate
property of the control:
dateTimePicker1.MinDate = DateTime.Today
精彩评论