473,320 Members | 2,112 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,320 software developers and data experts.

Commmon handling of Calendar controls

P K
I have around 20 calendar controls on my screen besides 20 textboxes.
The functionality of each control is the same, they take in a parameter for
the textbox name and open a calendar in a popup. And on selection the
textbox -identified by the name passed in the querystring , is populated.

Now, the 20 controls will have 20 event handlers. Is there a way I can have
one function (or event handler ) which would handle all the 20 calls.
What I mean is that instead of having different event handlers for each
calendar control, can I have just one for each of them ? And based on the
parameter passed I would identify the textbox?
Nov 19 '05 #1
1 1157
Use any of the following options:
1- Declaratively:
<asp:Calendar ID="calender1" Runat="server"
OnSelectionChanged="Calenders_SelectionChanged"></asp:Calendar>
<asp:Calendar ID="calender2" Runat="server"
OnSelectionChanged="Calenders_SelectionChanged"></asp:Calendar>

and so on..

2- in the code behind, add statements in the Page.Init eventhandler:

a. For C#,
this.calender1.SelectionChanged += new
System.EventHandler(this.Calenders_SelectionChange d);
this.calender2.SelectionChanged += new
System.EventHandler(this.Calenders_SelectionChange d);

b. For VB:
AddEventHandler calender1.SelectionChanged , AddressOf
Calenders_SelectionChanged

or
Private sub Calenders_SelectionChanged(sender as object, e as EventArgs )
handles calender1.SelectionChanged , calender2.SelectionChanged

In the method that handles the event:
private void Calenders_SelectionChanged(object sender, System.EventArgs e)
{
switch (((Calendar)sender).ID)
{
case "calender1": //process calender1
break;
case "calender2": //process calender2
break;
}
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"P K" wrote:
I have around 20 calendar controls on my screen besides 20 textboxes.
The functionality of each control is the same, they take in a parameter for
the textbox name and open a calendar in a popup. And on selection the
textbox -identified by the name passed in the querystring , is populated.

Now, the 20 controls will have 20 event handlers. Is there a way I can have
one function (or event handler ) which would handle all the 20 calls.
What I mean is that instead of having different event handlers for each
calendar control, can I have just one for each of them ? And based on the
parameter passed I would identify the textbox?

Nov 19 '05 #2

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

Similar topics

7
by: TDIOwa | last post by:
I have a form that has a specific date on it. I want to open another form that has the Active Control Calendar on it. I want to open this form to the specific date on the first form. I have...
5
by: Charles | last post by:
Hello, I would like for my users to have a calendar control only when needed. IE button click for the control to appear and then once the date is selected. Populate a text box and the calendar...
2
by: luca | last post by:
I'm trying to build a Server Control, it's a calendar to manage sellers appointments (don't answer me to use and custumize Calendar Control because unluckily it's not possible for this specific...
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...
2
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
27
by: Dino M. Buljubasic | last post by:
I'd like to build a calendar displaying all days in a month in a grid so that when I click on the header of a square representing a day of month, I can add a new meeting etc. I know that .net...
2
by: Mariano Padilla | last post by:
The calendar control only has the event of SelectionChanged 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...
2
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...
7
by: Vincent | last post by:
Does anyone know of any good 3rd party calendar controls that can be used in VBA? I am trying to find a calendar control that will allow you to select multiple dates at once or a range of dates,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.