By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

calendar SelectionChanged

P: n/a
I have a basic calendar and a SelectionChanged event (asp.net 2.0).

How can I handle it when a user chooses the same date again, in this case
the SelectionChanged event is not fired because, well, the date selected
hasnt changed.

Is there a calendar.clearSelection type method on the calendar I can use?
Mar 20 '07 #1
Share this Question
Share on Google+
24 Replies


P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:40**********************************@microsof t.com...
>I have a basic calendar and a SelectionChanged event (asp.net 2.0).

How can I handle it when a user chooses the same date again, in this case
the SelectionChanged event is not fired because, well, the date selected
hasnt changed.
That's absolutely right...
Is there a calendar.clearSelection type method on the calendar I can use?
What are you trying to do...? What do you want to happen if the user clicks
the calendar but the selection hasn't changed...?
Mar 20 '07 #2

P: n/a
All I am doing is placing the selected date into a textbox. It is a data
entry screen so sometimes the selected date will be the same as the last one.

Any way of handling this? I thought this would be a common problem.

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:40**********************************@microsof t.com...
I have a basic calendar and a SelectionChanged event (asp.net 2.0).

How can I handle it when a user chooses the same date again, in this case
the SelectionChanged event is not fired because, well, the date selected
hasnt changed.

That's absolutely right...
Is there a calendar.clearSelection type method on the calendar I can use?

What are you trying to do...? What do you want to happen if the user clicks
the calendar but the selection hasn't changed...?
Mar 20 '07 #3

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:F9**********************************@microsof t.com...
All I am doing is placing the selected date into a textbox. It is a data
entry screen so sometimes the selected date will be the same as the last
one.

Any way of handling this? I thought this would be a common problem.
I'm clearly not grasping the problem here...

You have a textbox and, presumably, a button or something which pops the
calendar, right...?

The user clicks a date, and the textbox is updated, right...?

At this point, don't you close the calendar...?
Mar 20 '07 #4

P: n/a
yes correct, I might be in the wrong forum. I should have added that I am
using ms ajax 1.0 and the calendar closes down fine. I kinda assumed this was
the same behaviour for non ajax apps.

So this works fine after the page postbacks?

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:F9**********************************@microsof t.com...
All I am doing is placing the selected date into a textbox. It is a data
entry screen so sometimes the selected date will be the same as the last
one.

Any way of handling this? I thought this would be a common problem.

I'm clearly not grasping the problem here...

You have a textbox and, presumably, a button or something which pops the
calendar, right...?

The user clicks a date, and the textbox is updated, right...?

At this point, don't you close the calendar...?
Mar 20 '07 #5

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:47**********************************@microsof t.com...
yes correct, I might be in the wrong forum. I should have added that I am
using ms ajax 1.0 and the calendar closes down fine. I kinda assumed this
was
the same behaviour for non ajax apps.

So this works fine after the page postbacks?
Apologies again - am still not grasping the problem...

If the calendar closes when the user selects a date, then how are they able
to click the date again...?
Mar 20 '07 #6

P: n/a
Sorry for the confusion.

Step 1:
User selects a date from the pop up and the date is put into a textbox using
the selectionChange event of the calendar. Calendar closes.

Step 2:
Do the same thing again and choose the same date you chose in first step.
The selectionChange event does not fire (as expected). So how can I clear the
selection or make the event fire.

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:47**********************************@microsof t.com...
yes correct, I might be in the wrong forum. I should have added that I am
using ms ajax 1.0 and the calendar closes down fine. I kinda assumed this
was
the same behaviour for non ajax apps.

So this works fine after the page postbacks?

Apologies again - am still not grasping the problem...

If the calendar closes when the user selects a date, then how are they able
to click the date again...?
Mar 20 '07 #7

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:D2**********************************@microsof t.com...
Sorry for the confusion.

Step 1:
User selects a date from the pop up and the date is put into a textbox
using
the selectionChange event of the calendar. Calendar closes.

Step 2:
Do the same thing again and choose the same date you chose in first step.
The selectionChange event does not fire (as expected). So how can I clear
the
selection or make the event fire.
Ah... Please post your code...
Mar 20 '07 #8

P: n/a
here is a very simple example of the issue.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb"
Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>

Code behind:

Partial Class test
Inherits System.Web.UI.Page

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Calendar1.SelectionChanged
TextBox1.Text = Calendar1.SelectedDate
End Sub
End Class

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:D2**********************************@microsof t.com...
Sorry for the confusion.

Step 1:
User selects a date from the pop up and the date is put into a textbox
using
the selectionChange event of the calendar. Calendar closes.

Step 2:
Do the same thing again and choose the same date you chose in first step.
The selectionChange event does not fire (as expected). So how can I clear
the
selection or make the event fire.

Ah... Please post your code...
Mar 20 '07 #9

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:89**********************************@microsof t.com...
here is a very simple example of the issue.
But I don't think that's the problem... Do you not have more code than this
e.g. a DayRender method which disables the SelectedDate or something when
the Calendar is opened...?
Mar 20 '07 #10

P: n/a
One option here, though I know it may not be what you're looking for, is to
have a button to set the date in the textbox, using the selected date in the
calendar
Other than that - when the calendar pops up, you could set the selected date
of the calendar to an alternate date....then, the selectionchanged event
would fire via their selection...

(just throwing out ideas here)

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"NH" <NH@discussions.microsoft.comwrote in message
news:40**********************************@microsof t.com...
I have a basic calendar and a SelectionChanged event (asp.net 2.0).

How can I handle it when a user chooses the same date again, in this case
the SelectionChanged event is not fired because, well, the date selected
hasnt changed.

Is there a calendar.clearSelection type method on the calendar I can use?

Mar 20 '07 #11

P: n/a
"David Wier" <da********@noSpamhotmail.comwrote in message
news:OK**************@TK2MSFTNGP03.phx.gbl...
Other than that - when the calendar pops up, you could set the selected
date
of the calendar to an alternate date....then, the selectionchanged event
would fire via their selection...
I usually don't do that - instead, I use the VisibleDate property to make
sure the Calendar displays the correct month, and then the DayRender event
to highlight the "associated" date in some way e.g. setting the BackColor to
Grey or something...

http://msdn2.microsoft.com/en-us/lib...te(VS.80).aspx
Mar 20 '07 #12

P: n/a
How do you disable the selected date when the calendar opens?

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:89**********************************@microsof t.com...
here is a very simple example of the issue.

But I don't think that's the problem... Do you not have more code than this
e.g. a DayRender method which disables the SelectedDate or something when
the Calendar is opened...?
Mar 21 '07 #13

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:23**********************************@microsof t.com...
"Mark Rae" wrote:
>"NH" <NH@discussions.microsoft.comwrote in message
news:89**********************************@microso ft.com...
here is a very simple example of the issue.

But I don't think that's the problem... Do you not have more code than
this
e.g. a DayRender method which disables the SelectedDate or something when
the Calendar is opened...?
Please don't top-post...
How do you disable the selected date when the calendar opens?
http://www.google.co.uk/search?sourc...ndar+DayRender

Mar 21 '07 #14

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:89**********************************@microsof t.com...
here is a very simple example of the issue.
<snip>

Is this the entire code for the the page in question...?
Mar 21 '07 #15

P: n/a
There is other code on the page, but its not related to the issue.

So I think you understand the issue? Do you know how to disable the
previously selected date when using the calendar on subsequent times.

You mentioned you disable the selected date in the dayRender method, what is
the code for that?

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:89**********************************@microsof t.com...
here is a very simple example of the issue.

<snip>

Is this the entire code for the the page in question...?
Mar 21 '07 #16

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:61**********************************@microsof t.com...

Please stop top-posting - it is very irritating...
There is other code on the page, but its not related to the issue.
Are you sure...?
So I think you understand the issue? Do you know how to disable the
previously selected date when using the calendar on subsequent times.
When you open a calendar, it doesn't have a selected date until you set its
SelectedDate property.

Create a completely new aspx page and put the following markup in it:

<asp:Calendar ID="calTest" runat="server" />

Now open the page and click the same date over and over again - no problem,
right...?

You say that you are able to click a date the first time the calendar is
opened but, when you open it a second time, you are unable to click the same
date.

This won't happen by itself - you must be doing it...

You say that the calendar is associated with a text box - how is it
associated with a text box...?
Mar 21 '07 #17

P: n/a
Top posting? What?

Anyways, so on the new page you created below you have added a calendar.
Thats fine. Now add a text box to the same page. Now add a
calendar.SelectionChange, something like this...

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Calendar1.SelectionChanged
TextBox1.Text = Calendar1.SelectedDate
End Sub
End Class

So choose a date from the calendar and the date goes into the textbox as a
result of the code above. Now clear out the textbox and choose the same date
again from the calendar. As the selected date has not changed the
calendar.selectionChanged event doesnt not fire as expected.

So how can you remove the previous selected date or make the
selectionChanege veent fire. Do you see the problem?

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:61**********************************@microsof t.com...

Please stop top-posting - it is very irritating...
There is other code on the page, but its not related to the issue.

Are you sure...?
So I think you understand the issue? Do you know how to disable the
previously selected date when using the calendar on subsequent times.

When you open a calendar, it doesn't have a selected date until you set its
SelectedDate property.

Create a completely new aspx page and put the following markup in it:

<asp:Calendar ID="calTest" runat="server" />

Now open the page and click the same date over and over again - no problem,
right...?

You say that you are able to click a date the first time the calendar is
opened but, when you open it a second time, you are unable to click the same
date.

This won't happen by itself - you must be doing it...

You say that the calendar is associated with a text box - how is it
associated with a text box...?
Mar 21 '07 #18

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...
Top posting? What?
Top posting... Placing your reply *above* the post you're replying to
instead of *below* it... Generally considered bad netiquette...
A - Because it interrupts the normal way of reading conversations i.e. from
start to finish

Q - Why is top posting irritating...?

So how can you remove the previous selected date
Calendar1.SelectedDate = Nothing
Mar 21 '07 #19

P: n/a
Thats not correct, I was replying to your earlier post. You had replied to
somebody else i.e. David.

Which event have you put the Calendar1.SelectedDate = Nothing into ?

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...
Top posting? What?

Top posting... Placing your reply *above* the post you're replying to
instead of *below* it... Generally considered bad netiquette...
A - Because it interrupts the normal way of reading conversations i.e. from
start to finish

Q - Why is top posting irritating...?

So how can you remove the previous selected date

Calendar1.SelectedDate = Nothing
Mar 21 '07 #20

P: n/a

"NH" <NH@discussions.microsoft.comwrote in message
news:BF**********************************@microsof t.com...
Thats not correct, I was replying to your earlier post. You had replied to
somebody else i.e. David.
FWIW, you're still top posting...
Which event have you put the Calendar1.SelectedDate = Nothing into ?
The one you mentioned:

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Calendar1.SelectionChanged
TextBox1.Text = Calendar1.SelectedDate
Calendar1.SelectedDate = Nothing
End Sub
Mar 21 '07 #21

P: n/a
That worked, thanks.

FWIW I am merely replying to the existing messages in the thread. What else
do you want someone to do?

"Mark Rae" wrote:
>
"NH" <NH@discussions.microsoft.comwrote in message
news:BF**********************************@microsof t.com...
Thats not correct, I was replying to your earlier post. You had replied to
somebody else i.e. David.

FWIW, you're still top posting...
Which event have you put the Calendar1.SelectedDate = Nothing into ?

The one you mentioned:

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Calendar1.SelectionChanged
TextBox1.Text = Calendar1.SelectedDate
Calendar1.SelectedDate = Nothing
End Sub
Mar 21 '07 #22

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:7B**********************************@microsof t.com...
That worked, thanks.
Hurrah!
FWIW I am merely replying to the existing messages in the thread. What
else
do you want someone to do?
You are placing the text of your reply *above* the text that you are
replying to... this is called top posting...
http://linux.sgms-centre.com/misc/ne...te.php#toppost

There are some groups where top posting will actually get you banned... :-)
Mar 21 '07 #23

P: n/a
Ah now I see what you mean. Thats funny because I dont like it when people
add in there text at the end of the messages. You have to scroll all the way
down just to read one line or something. I guess everyone has their own
preference. And I am top posting again :)

"Mark Rae" wrote:
"NH" <NH@discussions.microsoft.comwrote in message
news:7B**********************************@microsof t.com...
That worked, thanks.

Hurrah!
FWIW I am merely replying to the existing messages in the thread. What
else
do you want someone to do?

You are placing the text of your reply *above* the text that you are
replying to... this is called top posting...
http://linux.sgms-centre.com/misc/ne...te.php#toppost

There are some groups where top posting will actually get you banned... :-)
Mar 21 '07 #24

P: n/a
"NH" <NH@discussions.microsoft.comwrote in message
news:08**********************************@microsof t.com...
Ah now I see what you mean. Thats funny because I dont like it when people
add in there text at the end of the messages. You have to scroll all the
way
down just to read one line or something.
That's almost as bad, though at least that doesn't mess up the natural flow
of the thread...

Anyway, no biggie - you're problem is resolved, which is the main thing...
:-)
Mar 21 '07 #25

This discussion thread is closed

Replies have been disabled for this discussion.