473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Calendar control weirdness - one post behind?

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
Nov 18 '05 #1
2 1375
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

"D. Shane Fowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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


Nov 18 '05 #2
<slapping forehead>
Of course! OnSelectionChanged.

Thanks!
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:eS**************@TK2MSFTNGP10.phx.gbl...
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

"D. Shane Fowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Steve | last post by:
Can someone recommend a way to display a one-month calendar view where the month can be selected and up to six events can be shown in any day of the calendar. The events and dates would be stored...
1
by: Joey Durham | last post by:
Hi, Hope this is the correct forum to post in. I am new to ASP.NET. I have a calendar control that I am using to select a date and then that date will list all records that match the date...
2
by: js | last post by:
Any way to modify an <asp:Calendar> tag with parameters on the fly? Seems I'm not allowed to use the <% =xxx %> substitution for parameters to the <asp:Calendar> tag. Do I have to do code...
2
by: Chuck Hartman | last post by:
I've been trying to add an ImageButton object to a Calendar table cell, but so far I am unable to handle the Command event from that button in my form's code behind. Below is an example of what I...
4
by: Nad | last post by:
Hello, I have a user control that has a button and a Calendar. Once you click on the button I display the calendar. Now when I move this user control to a web form, once I click on this button...
4
by: ShyGuy | last post by:
A while back I had found a link to a popup calendar that had a small button that was placed to the right of any text box. By clicking on the icon and selecting a date the text box was updated with...
7
by: John Kotuby | last post by:
Hi all, I am trying to use a calendar server control which I have ID="Calendar1" in the source code. What I am trying to do is emulate a JavaScript calendar that was being used in an older ASP...
4
by: BillE | last post by:
Can I make the Ajax calendar extender appear on top of dropdown lists instead of behind them? Thanks Bill
1
by: BMW | last post by:
The Calendar Control in ASP.NET form was overlapped by other controls, i.e. textbox... Anyone know how to handle it. Thank you very much!
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.