473,836 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Possible Bug In the Calendar Control on web forms.

The calendar control only has the event of SelectionChange d to detect if the
user clicks on the calendar. I have 2 calendars on a form, one for arrival
date one for departure date. Every time a use clicks on the calendars, the
proper date gets filled in the text boxes below the calendars.

I noticed that if you click on the date correspinding to the current date,
the textboxes do not get filled or changed. Is this a bug? If not how can I
detect that the user clicked on today's date?
Jan 28 '06 #1
2 1839
On Fri, 27 Jan 2006 16:20:27 -0800, Mariano Padilla
<Ma************ @discussions.mi crosoft.com> wrote:
The calendar control only has the event of SelectionChange d to detect if the
user clicks on the calendar. I have 2 calendars on a form, one for arrival
date one for departure date. Every time a use clicks on the calendars, the
proper date gets filled in the text boxes below the calendars.

I noticed that if you click on the date correspinding to the current date,
the textboxes do not get filled or changed. Is this a bug? If not how can I
detect that the user clicked on today's date?


Actually, when processing data from controls on a form you should read
the data from the controls before processing a submit, so you can
validate the entries. What if the user manually changes one of the
text boxes without using the calendar control?

But, below is an example of how to accomplish your requirement.

You will need to accept that the default date is DateTime.Today. If
you design this way you will know that if the user does not choose a
date, the date is the default.

If the user chooses a new date the event will fire and you can handle
that. If the user has chosen a different date than today and then
chooses today as the date again, the event will fire, because today
becomes the SelectedDate.

1. Set Calendar.Select edDate to DateTime.Today
2. Set TextBox.Text to DateTime.Today
3. If you want to capture the date of the Calendar/TextBox as an
event, set a variable to DateTime.Today

Now you have set the default date on load to today.

Supposing you have a private DateTime field named _userChosenDate , the
code below does as you want.

private DateTime _userChosenDate ;

public partial class _Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
Calendar1.Selec tedDate = DateTime.Today;
TextBox1.Text = DateTime.Today. ToString("MM/dd/yyyy");
_userChosenDate = DateTime.Today;

}
protected void Calendar1_Selec tionChanged(obj ect sender, EventArgs
e)
{
TextBox1.Text = Calendar1.Selec tedDate.ToStrin g("MM/dd/yyyy");
_userChosenDate = Calendar1.Selec tedDate;
}

I hope this has been helpful to you.

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Jan 28 '06 #2
On Sat, 28 Jan 2006 10:29:36 -0600, Otis Mukinfus
<ph***@emailadd ress.com> wrote:

In line...
On Fri, 27 Jan 2006 16:20:27 -0800, Mariano Padilla
<Ma*********** *@discussions.m icrosoft.com> wrote:
The calendar control only has the event of SelectionChange d to detect if the
user clicks on the calendar. I have 2 calendars on a form, one for arrival
date one for departure date. Every time a use clicks on the calendars, the
proper date gets filled in the text boxes below the calendars.

I noticed that if you click on the date correspinding to the current date,
the textboxes do not get filled or changed. Is this a bug? If not how can I
detect that the user clicked on today's date?


You must have already set the default date in the calendars to the
current date.

When investigating further I discovered if you do not set a date as
default in the calendar control it will fire the SelectionChange d
event even when you click the current date. To make this work as you
originally expected, do not set a default date on any of the calendar
controls.
Actually, when processing data from controls on a form you should read
the data from the controls before processing a submit, so you can
validate the entries. What if the user manually changes one of the
text boxes without using the calendar control?

But, below is an example of how to accomplish your requirement.

You will need to accept that the default date is DateTime.Today. If
you design this way you will know that if the user does not choose a
date, the date is the default.

If the user chooses a new date the event will fire and you can handle
that. If the user has chosen a different date than today and then
chooses today as the date again, the event will fire, because today
becomes the SelectedDate.

1. Set Calendar.Select edDate to DateTime.Today
2. Set TextBox.Text to DateTime.Today
3. If you want to capture the date of the Calendar/TextBox as an
event, set a variable to DateTime.Today

Now you have set the default date on load to today.

Supposing you have a private DateTime field named _userChosenDate , the
code below does as you want.

private DateTime _userChosenDate ;

public partial class _Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
Calendar1.Selec tedDate = DateTime.Today;
TextBox1.Text = DateTime.Today. ToString("MM/dd/yyyy");
_userChosenDate = DateTime.Today;

}
protected void Calendar1_Selec tionChanged(obj ect sender, EventArgs
e)
{
TextBox1.Text = Calendar1.Selec tedDate.ToStrin g("MM/dd/yyyy");
_userChosenDate = Calendar1.Selec tedDate;
}

I hope this has been helpful to you.

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com


Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Jan 28 '06 #3

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

Similar topics

1
2066
by: Marco Simone | last post by:
Hi, If someone can answer how to add calendar control on form, where you can choose date. I think there is Calendar control in ActiveX add in, but I don't know how to implement it. Thanks for your help, Marco
2
1789
by: Ima Lostsoul | last post by:
I cant seem to set the date on the calendar control. What i want to happen is have a form pop up when a button is clicked (have that part of course). This for has a calendar control on it. I have the code to pass the date selected back to the original form working just fine. I want to have the calendar start with whatever the current date is as the selected date -or- a specificed date passed to the form (by a global variable) based on...
3
8237
by: Matthew | last post by:
I currently have a form in MS Access that has certain combo boxes which specify criteria in order to run a query based on that criteria. I want to add to this, a calendar from which a user will be able to click on a date, where the chosen date will then be used as the criteria for the control source of the calendar. What do I need to do to make the calendar active?? I can physically get it on my form, and specify the criteria in my...
2
3771
by: jodyblau | last post by:
I am trying use a Calendar Control 10.0 in one of my forms. (I am using access 2002) What I want to do is have the user click a button which makes the calendar visible. Then when the user clicks on a date, it sends it to a text box and then the calendar should disappear. All of the examples I have been able to track down seem to use events that aren't available to me. Most notably, any click events.
7
8101
by: Mike Charney | last post by:
I am trying to use the calendar control in Access (Calendar Control 11.0) I have it working but for only one form. I do not know VB/VBA very well, but how can I open the calendar control, which is on a form called frmcalendar, so that all I have to do is click or double click a date and the date is transferred back to the calling form? I have looked at several outside calendars but I don't want to use them. I would rather stick with...
5
2225
by: msch-prv | last post by:
I created a pop-up window using the ASP.NET 2.0 calendar in a distinct file (calpopup.aspx). The calendar pops up when clicking on a linkbutton and copies the selected day back into the textbox. This works fine in IE. In Firefox however, while the calendar is displayed correctly, the date is not copied back. The console javascript reports the error: 'window.opener.document.forms is not a function'. How can I trick FF into executing...
6
3381
by: Tony Girgenti | last post by:
Hello. Developing a VS2005, SP4, VB, .NET 2.0, ASP.NET 2.0, web site program using a calendar. I tried using the validators to see if i can validate dates using a calendar control. It does not allow me to select the calendar control in the drop-down list for the ControlToValidate property. Is it possible to do client-side validation of calendar dates?
14
2263
by: magmike | last post by:
Can I do anything with the calendar buttons? I want to display a number on the buttons. I'm using the calendar control on a form that sets a call back date and time. The user can click on the calendar if they wish to set the date in the date field. It also serves the purpose of using a calendar. Also on that form, I have a subform that shows a query which shows the count of call backs set for each date. I would like to be able to...
4
2685
by: phill86 | last post by:
Hi, I am trying to represent on a form time slots I have re-created the look of an outlook calendar on the form I have a table with the calendar bookings start and end time and there could be any number of bookings in a day. The following code represents the column for the first day of the week (monday) and formats the text boxes accordingly if the room is booked. This all works fine but I have to have this code again to represent the...
0
9820
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9671
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10549
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9376
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6979
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4019
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.