473,396 Members | 1,755 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,396 software developers and data experts.

Get the same selected date from the calendar two consecutive times

mg

When I click any date in System.Web.UI.WebControls.Calendar (C# WebForm), the SelectionChanged event handler fires. If I next click on the same date again, this event handler does not fire, so I can't get the selected date directly from the calendar on two successive attempts

How can I get this same selected date from the calendar on two successive attempts. Storing the value obtained on the first attempt isn't helpful.
Nov 18 '05 #1
2 1933
This might be a hack but it seems to work... call SelectionChanged
yourself....

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If IsPostBack Then
If viewstate("stopcalendarchange") _
<> True Then
Call Calendar1_SelectionChanged _
(Calendar1, Nothing)
End If
End If
End Sub

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

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
viewstate("stopcalendarchange") = True
Label1.Text = "Stopped getting same date."
' Calendar1.Enabled = False
' Calendar1.Visible = False
End Sub

<form id="Form1" method="post" runat="server">
<asp:Calendar id="Calendar1" runat="server"></asp:Calendar>
<P>
<asp:Label id="Label1" runat="server"></asp:Label></P>
<P>
<asp:Button id="Button1" runat="server" Text="Stop getting same
date"></asp:Button></P>
</form>

Ken
Microsoft MVP [ASP.NET]

"mg" <mg@theworld.com> wrote in message
news:4C**********************************@microsof t.com...


When I click any date in System.Web.UI.WebControls.Calendar (C# WebForm),
the SelectionChanged event handler fires. If I next click on the same date
again, this event handler does not fire, so I can't get the selected date
directly from the calendar on two successive attempts.

How can I get this same selected date from the calendar on two successive
attempts. Storing the value obtained on the first attempt isn't helpful.


Nov 18 '05 #2
mg
Thanks

Any chance of getting the C# version of this code?
Nov 18 '05 #3

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

Similar topics

1
by: Sara | last post by:
I am trying to use MDX to dynamically determine which hierarchy of the time dimension is selected. I have a calculated member which is using the last non-empty descendant of the . dimension, but...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
4
by: Geir Baardsen | last post by:
Hi! I have the following headpuzzle: On a form (frmAgenda) I have a calendar control and a listbox. When user clicks date in calendar, the listbox will show some information that will be...
1
by: Chanaka | last post by:
We are trying to pass the selected date from a .net calendar in a querystring. We manage to display the selected date from the calendar in a Lable like this : protected void...
7
by: No bother | last post by:
I have a table which has, among other fields, a date field. I want to get a count of records where certain criteria are met for, say, three days in a row. For example: NumWidgets Date...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
5
by: Mark Olbert | last post by:
I just noticed something weird about the calendar control in ASPNET2. If you assign a value to SelectedDate that has a time component (e.g., 3/1/2007 10:37 AM), and you have a custom style for the...
1
by: EyeHawk | last post by:
OK, hopefully somebody can help me out again. My next problem is updating 3 form fields (type list/menu option) that correspond to a date, one for month, one for day and one for year when the user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.