Calendar control click event

V

Vishal Gupta

Hello:

I have a calendar control that defaults to today as the selected date.
Problem is, if the user clicks on the selected date then since there is no
change in date the SelectedChanged does not fire. There is no other control
event that fires either. How do I acknowledge the user selection of a
pre-selected date?

Thanks.
 
K

Ken Cox - Microsoft MVP

One workaround is to force a call to the SelectionChanged handler if the
date hasn't changed.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Calendar1.SelectedDate = Viewstate("SelDate") Then
Call Calendar1_SelectionChanged(Calendar1, e)
End If
End Sub


Private Sub Calendar1_SelectionChanged _
(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Calendar1.SelectionChanged
Viewstate("SelDate") = Calendar1.SelectedDate
Label1.Text = Calendar1.SelectedDate.ToLongDateString & _
" selected at: " & Now.ToLongTimeString
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top