Calendar control weirdness - one post behind?

  • Thread starter D. Shane Fowlkes
  • Start date
T

Teemu Keiski

Hi,

because postback events (where changes happened in control state are
detected) are raised after Page_Load, the state of the Calendar has not yet
been updated in Page_Load. You get the SelectedDate for sure by having a
handler for Calendar's SelectionChanged event. In this event handler you'll
get the correct date from the SelectedDate property.

Private Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Calendar1.SelectionChanged
lblSelectedDate.Text = Calendar1.SelectedDate
End Sub
(My example is written with VS.NET so it uses code-behind. You might want to
declare the event handler in aspx if you use inline mode.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

http://www.drumpub.com/caltest.aspx

Check the test page at the above link. Could someone please tell me why I'm
capturing the calendar's SelectedDate "one post behind"? The source code is
on the page too.

Thanks!

Shane
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top