PopUp Calendar
page 1 of 1
Published: 07 Oct 2003
Unedited - Community Contributed
Abstract
When we enter text in a web page, especially during a Form-Filling, Registration, searching, lookup... We always have to fill in a Date, actually we can "PopUp" the Calendar, select a Date and then send this value back to the parent WebForm.
by Colt Kwong
Feedback
Average Rating: 
Views (Total / Last 10 Days): 124070/ 358

PopUp Calendar

When we enter text in a web page, especially during a Form-Filling, Registration, searching, lookup... We always have to fill in a Date, although the rich Calendar control exist, while many people (including me) like to "PopUp" the Calendar, select a Date and then send this value back to the parent WebForm. As it would not only save our limited screen space on a WebForm, and we can also provide a better user experience. 

As we all know that, we have to use Javascript (window.open) to pop up a new browser window in a Asp.Net WebForm. However, how can we create the thing like DatePicker in a WebForm? how do we know which TextBox Control is going to be populated? How to send the selected date to the parent WebForm?

Therefore, a lots of commerical PopUp Calendar / Date Picker Control was born for this need. In this article, I'll show how to write a PopUp Calendar by yourself! i.e. PopUp a Calendar, change the Month and Year dynamically, and then send back the selected Date on the Calendar Control to the 'corresponding' TextBox(es) on the Parent WebForm!

<asp:TextBox id="txtEndDate" runat="server"/>
<a href="javascript:GetDate('txtEndDate')">
  <img alt="PopUp Calendar" src="../Images/SmallCalendar.gif" border="0" />
</a>

I wrote a small Javascrip function, which accept the control ID as an parameter, and then pop up a new browser window. In the same time, I'll pass 2 variables in the QueryString: WebForm and Control ID.

Why do I have to use Javascript to get the WebForm ID? Yes, the default WebForm ID created by VS.NET is "Form1", that mean you can hardcode it without any change/code. However, no WebForm ID is available in design time under WebMatrix by default, so we have to make sure that the correct WebForm as the parent WebForm. (As I'm a WebMatrix fan too... ) Therefore, we have to use pass these info: Which control have to be filled and what's the Form name.

Next, we create 3 Page-wide String Object in the child window (strSelectedDate, strFormName & strCtrlName) - each of them are used to store the Selected Date from the Calendar control, Parent Form ID and Requesting Control ID.

The first one can be filled in the OnSelectedIndexChanged event handler upon user click on a date. The other two are populated by the values in the QueryString. Finally, the most important part would be 'Passing the selected value back to the requesting control on the parent WebForm'. So we can:

1. reference to the parent window:
window.opener

2. reference to the parent WebForm:
window.opener.document.forms["<%= strFormName %>"]

3. reference to the requesting control in the parent WebForm:
window.opener.document.forms["<%= strFormName %>"].elements["<%= strCtrlName %>"]

So, we can assign the String object with the Selected Date value back:
"<%= strSelectedDate %>"

In this javascript, we'll make use of the 3 temporary String Object and then assign the value back to the control on the window.opener WebForm. Well... You can sure change the format of the selected Date on the TextBox(es) for your own by handling in the myCalendar_SelectionChanged event handler, and I used the format of "dd/MM/yyyy" in my demo. 



* Thanks for the feedback of Steve, and I made an enhancement in the PopUp Calendar. That's the Child (PopUp) window will be closed along with the close of parent window now. As an "Access Denied" like exception will be thrown if the Parent window was close suddenly while keeping the child window opened, as the child window don't know how to return the selected date value to a NULL object.

Demo           Download (Parent)            Download (PopUp Child)



User Comments

Title: cccxx   
Name: cxcxcx
Date: 2012-05-07 4:30:32 PM
Comment:
xccxcxcx
Title: calender popup   
Name: swat
Date: 2011-02-28 5:22:47 AM
Comment:
can i know how to create a calender popup in
asp.net using c#???
Title: good   
Name: Santhu
Date: 2010-03-29 1:48:51 AM
Comment:
nothing is working. kindly check ur code and then upload in appropriate manner. This fool us!
Title: Thanx   
Name: Rejeesh
Date: 2010-03-07 1:55:12 AM
Comment:
Thanx a lot Colt Kwong.
You are God...searched a lot of PopUp calendars...but none were working.
Finally this one is working...
though i got a null reference error in the code where its trying to put today's date as default date,but as calendar is upto only 2005...i just commented these lines & it was working fine.
Thanx a lot again...
Title: MasterPageFile   
Name: Klapteendiekop
Date: 2010-03-03 6:39:32 AM
Comment:
Hi, Just redo this demo for asp.net 3.5 and save us all alot of headache!!
Title: CalendarPopup   
Name: Prasad
Date: 2009-10-12 1:04:44 PM
Comment:
Hi,
I want to know is it possible to enable 'CalendarPopup' to select previous date?
I have 'CalendarPopup'. The value (date) was set to 90 working days after today. Now user wants to select previous date (in those 90 days).
Please help...
Title: calender   
Name: swapna
Date: 2009-10-03 7:17:06 AM
Comment:
calender demo downloads are not working
Title: Demo   
Name: Eyveneena
Date: 2009-08-20 11:58:35 PM
Comment:
THe demo is not working
Title: Insert selected date into textfield(in datagrid) from ParentWindow   
Name: JP
Date: 2009-07-22 7:10:05 AM
Comment:
Solved.
The Problem was that the String "strCtrlName" had to contain the ID of the Textfield in the Datagrid.

href="javascript:GetDate('<%= df_Date.ClientID%>')"
now it works perfect for Textfields inside of a Datagrid.
Nice Tutorial love it ;)
Title: Insert selected date into textfield(in datagrid) from ParentWindow   
Name: JP
Date: 2009-07-22 6:24:03 AM
Comment:
hello,
Awesome Idee, how to create a PopUpCalendar, thanks.
I have a problem with selecting a Date in the PopUpcalendar and than to insert it into the textfield in a datagrid in the parent window.

alert(window.opener.document.forms["<%= strFormName %>"].elements["<%= strCtrlName %>"]) says its "undefined".
strFormName = "Form1" and strCtrlName = "df_Date".

I think its because the textfield is in a datagrid thats why it can`t be found. Maybe its a Problem with IE 7. Don´t know.
Somebody Help, please.
Title: calender   
Name: guna
Date: 2009-03-17 3:33:46 AM
Comment:
how can i insert data against some perticular date of a calender - asp:calender?

ple send code
Title: Pop up problem   
Name: Smita
Date: 2009-02-17 6:23:49 AM
Comment:
hi I am passing values from pop up to parent window,but not getting access to parent window's elements,as paren window is using frame.
i tried this code
window.opener.document.getElementById('birthDate'+bcount).value

which gives me error as
window.opener.document.getElementById('birthDate'+bcount) has no properties..
thnks
Title: Help   
Name: Ranjan Srivastava
Date: 2008-12-05 7:00:22 AM
Comment:
I want , when I click in the textbox then a calender will open and i select a date and time from it.

Plz send the code
Title: HELP!!! Does anyone have a C# code   
Name: krisjohn
Date: 2008-10-27 4:04:14 PM
Comment:
This is a great tutorial... But I need a c# code... Can anyone help me.

You can send it to my email: katski_01@yahoo.com
Title: Thats Excellent Use of JavaScript Parent & Child Control   
Name: Mohammed P
Date: 2008-09-24 9:06:28 PM
Comment:
Nice use of the sharing the data between the parent and child control, Please do let me know about how to get this advance knowledge of javascript. if you do have good resource do reply
Title: Solution For Master Page   
Name: Asmita
Date: 2008-08-19 3:46:19 AM
Comment:
Thanks Alot Munmun Guha it works. solution is
You just have to do this
javascript:GetDate('<%=txtStartDate.ClientID%>')
Title: AUTO CHILD WINDOW CLOSE   
Name: DEV
Date: 2008-06-01 12:17:11 AM
Comment:
HI THANKS FOR THE CODE. IT ROCKS. I HAVE A SITUATION WHERE THE USER POPS UP THE CALENDAR AND DOES NOT MAKE A SELECTION AND INSTEAD CLICKS ON THE FORM.AT THE INSTANCED THE CHILD OR CALENDAR SHOULD CLOSE.RIGHT NOW IT HIDES BEHIND THE PARENT WINDOW.WE ARE USING .NET 1.1 VISUAL STUDIO 2003.

THANKS FOR YOUR HELP IN ADVANCE.
Title: Working Code   
Name: Munni
Date: 2008-05-13 10:46:22 AM
Comment:
Hi all,

Even I tried a lot to implement the code. But this link shows a perfect working code and so simple.

http://forums.asp.net/t/1260086.aspx

Enjoy coding
Title: Please Advice   
Name: sameera
Date: 2008-05-06 5:15:05 AM
Comment:
Hye..
i have a textbox and a calendar control..i m getting the date on my textbox accurate but wen i m setting readonly = true for my textbox..i m unable to get the selected date in codefile..
Please tell is this a bug in ASP.Net 2.0 or have to do some other technique???
Title: Help   
Name: jitendra
Date: 2008-05-03 1:54:07 AM
Comment:
Hey do you have any C# code for this, the example is great can you send me the C# code please......
my email id is jitendra_patil2006@yahoo.com
Title: Help.....   
Name: Victor
Date: 2008-04-20 1:02:26 PM
Comment:
i am using a master page and i popup a calander page. how can i return value to the master page's textbox.
i have tired window.opener.document.aspnetForm.Ct00.Contentholder1.txtDate.value = '04/05/2008'
Title: HELP   
Name: SUGANYA
Date: 2008-03-31 6:27:38 AM
Comment:
I WANT TO ADD POPUP CALENDAR FOR MY FORM TO DISPLAY YEARS OF EXPERIENCE.. HOW CAN I DO THAT?
Title: get the date and time from calander   
Name: alisha mehta
Date: 2008-03-10 4:45:05 AM
Comment:
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if (TextBox1.Text.ToString()!= null)
Calendar1.SelectedDate = Convert.ToDateTime(TextBox1.Text);
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToString();

}
Title: PopUpCalendar   
Name: Syed Abuthahir
Date: 2008-02-27 10:15:54 AM
Comment:
When i tried the same with grid. it gives the following error

Microsoft JScript runtime error: 'window.opener.document.forms.form1.elements.TextBox1' is null or not an object
the moment when i click the Select button, it throws this exception.,

here TextBox1 is an EditItemTemplate in Grid.
Title: dot net   
Name: kapil chaturvedi
Date: 2008-02-22 2:36:59 AM
Comment:
i would like to set the month and year at the run time of asp page. kindly provide help...
Title: PopUp Calender   
Name: Sankar
Date: 2008-02-16 1:12:25 AM
Comment:
Hi,
i got the same functionality for grid.
Thanks for giving this article.
it's very uesful.
Title: PopUp Calender   
Name: Sankar
Date: 2008-02-15 5:24:18 AM
Comment:
hi,
its a good one for me.
and i want the data of a grid to be displayed from popup window to the main window.
can i have some more suggesstions from your side regarding the above mentioned one.

my mail id is sankar.vajrala@gmail.com
Title: Customizing Calender   
Name: Priyanka
Date: 2008-02-14 10:46:35 PM
Comment:
Hi
I want to customize view of calender .I want to display a link with a particular date. How can i do this?
Title: Popup calendar   
Name: swapna
Date: 2008-02-13 2:31:37 AM
Comment:
Hi

Iam swapna.Actually i saw the pop up calendar code.but i couldn't get your code.Iam beginner of .net.How to implement this by using master page registration page(using sql server) and normal aspx page(without use master pages).

Please Help me asap.This is very helpful for me.

My mailId is swapnacm1999@gmail.com
Title: help   
Name: Hal
Date: 2008-02-06 3:26:37 AM
Comment:
when postbak value of textbox returned to empty, any possible ways?
Title: It's Work   
Name: S
Date: 2008-02-01 2:01:24 PM
Comment:
Niiiiiiiiiiiice Thanx Alot
Title: please   
Name: Avdhesh
Date: 2008-01-22 3:22:23 AM
Comment:
I connected popup calendar to a textbox, which is readonly. The text box is unable to maintain its value after postback. How I can solve the problem. Please help me.....
Title: calendar   
Name: komail
Date: 2008-01-19 1:16:56 AM
Comment:
how to apply calender control without postback
Title: Master content Page Solutions!!!!!!   
Name: Munmun Guha
Date: 2008-01-17 1:01:24 PM
Comment:
You just have to do this
javascript:GetDate('<%=txtStartDate.ClientID%>')


Munmun
Title: Master content Page   
Name: Munmun Guha
Date: 2008-01-17 12:12:41 PM
Comment:
I am also having problem when I am using master content page like others. The strformnae= aspnetform
The select button is not returning any date on my content pages text box.

Please please need any solutions asp.Help me

Can contact by email munmun.guha@unapen.com

Munmun
Title: sad   
Name: Sudip
Date: 2008-01-11 5:11:37 AM
Comment:
When using the Calendar Popup in a content page of a masterpage the strForName is always set to aspnetForm
This breaks this line from working properly
window.opener.document.forms["<%= strFormName %>"]......

How can I fix this?
Title: help me   
Name: shivraj singh
Date: 2007-12-26 6:54:18 AM
Comment:
I connected popup calendar to a textbox, which is readonly. The text box is unable to maintain its value after postback. How I can solve the problem. Please help me.....
Title: Please help me   
Name: shivraj singh rajawat
Date: 2007-12-11 12:24:05 AM
Comment:
I connected popup calendar to a textbox, which is readonly. The text box is unable to maintain its value after postback. How I can solve the problem. Please help me......
Title: Thanks   
Name: Neha
Date: 2007-12-10 12:19:27 AM
Comment:
I was stuck on this problem for a whole day.Thanks a lot for your help.
Regards.
Title: Example calendar use master page   
Name: Nor
Date: 2007-12-04 12:48:11 PM
Comment:
Dear Cold,
You have an example this calendar use master page, I select
date in calendar but not work assign value in textbox.

Thanks for you help.
Regards.
Title: pop-up in usercontrol   
Name: Nan
Date: 2007-12-02 10:19:54 PM
Comment:
How can i create this pop-up in my usercontrol.
Title: is there any change for asp.net 2 with c#   
Name: Lokesh Bhardwaj
Date: 2007-11-06 2:00:06 AM
Comment:
I want to implement this funda with asp.net 2 but the command window.opener.document is not working with that.

date is selected but not returned to the parent window element.

With regards
Lokesh
Title: Awesome   
Name: kmcq
Date: 2007-10-03 4:48:43 PM
Comment:
Thank you, you saved me hours of work. All I had to do was figure out how to get this to work on masterpages!

The answer is in the GetDate function call...

If Not IsPostBack Then Button2.Attributes.Add
("OnClick", "javascript:GetDate('" & txtdate.ClientID & "');")
Title: PopUp Calendar   
Name: Jyothi
Date: 2007-09-26 5:51:15 AM
Comment:
It helps me, Thanks Alot.
Title: Pretty kool   
Name: Jitu
Date: 2007-09-11 5:54:48 AM
Comment:
Yeah, I had requirement just similar to this. This information was very useful to me.

Thank You

Keep Rocking
Title: it doesn't work when the textbox is contained by wizard control   
Name: ruxan
Date: 2007-09-06 9:47:41 PM
Comment:
This is a great example but unfortunately it doesn't work if the textbox is contained by a wizard control. I tried it and a few other samples online and nothing works. I know that all we need to do here is to fix the return function to capture that textbox is within wizard control but that is exactly the problem. I didn't find any documentation to illustrate that and also tried many variations of FindControl and still pointless... Anybody has any ideas?
Any help will be appreciated!!!
Title: Problem   
Name: Manu
Date: 2007-09-03 7:31:11 AM
Comment:
window.opener.document.forms["<%= strFormName %>"].elements["<%= strCtrlName %>"].value = "<%= strSelectedDate %>";
is not working
Title: getting value of textbox in case of master pages   
Name: navneet
Date: 2007-08-30 6:48:00 AM
Comment:
hi........
m navneet.....my id is nav_priyu@yahoo.co.in...m getting problem during accessing value of textbox while using master pages...actually m updating value of textbox...bt it doesnt updatting...its fetching an old value....after click event of update...please help me if any1 hv any suggestion....
Title: getting text value after postback   
Name: praveen
Date: 2007-08-27 12:46:54 AM
Comment:
hi im praveen, my id is sivarampraveen@gmail.com. I'm using a pop-up calender in my web page,but the text box into which the date is coming can be editable. so users can change the date value, please help me with sample code which cannot make the users edit the text box value.
Title: help me out   
Name: pavani.k
Date: 2007-08-13 3:23:30 AM
Comment:
hi my id is pavanikorasapati@yahoo.co.in.pls send me the code for popup calendar in asp
Title: help me out   
Name: pavani.k
Date: 2007-08-13 3:21:40 AM
Comment:
Hi,
Can I do this popup calendar from asp.please send me the code
Title: please help   
Name: mamata
Date: 2007-08-10 3:01:05 AM
Comment:
hi
i am using calender and enter start_date & end_date in two text box.how to get no of days in third text box.
please send me code
my id:mamata_kamat@fineng.com
Title: Please advise   
Name: Verlin
Date: 2007-07-23 6:48:02 PM
Comment:
Hi,
Can I do this popup calendar from asp or it has to be aspx?
Title: Please Help   
Name: Sunitha
Date: 2007-07-10 11:22:29 AM
Comment:
Hi:

Can someone send me the code on how to use the popup calendar in the master pages. I've a problem populating the text box with the selected date.
My emailID is : garnenis@yahoo.com
Title: this is very useful for me   
Name: vijay kumar
Date: 2007-07-06 6:12:55 AM
Comment:
this is very useful for me
Title: pop up calendar doesn't work in gridview   
Name: Thinktank
Date: 2007-07-02 12:19:01 AM
Comment:
Hi has anyone tried it in gridview edit mode?
I don't seems to get it to work?
Any help is deeply appreciated.
Title: plz F1   
Name: Mahsa
Date: 2007-06-26 3:40:42 AM
Comment:
Hi Dear
I Want to Learn EveryThing About PopUp............
What am I doing?
What Pdf I can Read?
Please help Me
Thanks!
Title: pop up Calendar doesn't work inside FormView   
Name: Emeleen
Date: 2007-06-22 1:34:34 PM
Comment:
OOPS! Sorry copied the wrong code..

Here is the correct one!

href=javascript:GetDate('<%=FormView1.FindControl( "Textbox1").ClientID%>')
Title: pop up Calendar doesn't work inside FormView   
Name: Emeleen
Date: 2007-06-22 12:55:54 PM
Comment:
Hello,

Has anybody found out how to pass the value of the selected date to the textbox inside a formview?

the link:
href="javascript:GetDate('Txt_FromDate')"

doesnt work in my code.

Thanks!
Emeleen
Title: about pop up calender   
Name: Latha
Date: 2007-06-22 2:01:54 AM
Comment:
Hai,
Popup calender is not working .Could you please how to do tell me
Title: Getting the value back from using web control form (ascx)   
Name: Dp
Date: 2007-06-19 10:03:05 PM
Comment:
Hi,
Currently I'm creating a pop up calendar inside the web control page (ascx), then putting it inside the master web form (aspx) page. When running the system, the calendar pop up, but when i select on the certain date, it seems that it does not return any help, could someone enlighten me about on what actually went wrong with it.
Can mail me back at dolphin0382@yahoo.com.sg
thanks
Dp
Title: Error: "textbox" is Null or not an object   
Name: smc
Date: 2007-06-16 11:27:15 AM
Comment:
Error: "textbox" is Null or not an object
When I check the value of textbox it is correct. Because the parent page is made from a master page the form name is aspnetform. Then the textbox name is invalid.... any ideas?
Title: Javascript problem in passing control name   
Name: Karan Saini
Date: 2007-06-05 8:44:54 AM
Comment:
Hello,

I tried to use the calendar control inside the EditItemTemplate of the FormView control (ASP.NET 2.0).

But i am not able to pass the control name successfully like u did in the example:-

href="javascript:GetDate('Txt_FromDate')"

Can anyone suggest how to pass the textfield name present in the formview?

Please mail me back at sainisherry@yahoo.com

Thanks

Karan
Title: Calender Popup Control in Windows application   
Name: Sugumar.R
Date: 2007-05-18 1:23:15 AM
Comment:
Hi,
Your Demo was very good and I am trying to Create a Calender Pop up User control in Windows application using C#.Net. Can you help me in this regard?

Thanks
Sugumar.R
Title: PopUp Calendar in C#   
Name: KT
Date: 2007-05-07 11:16:40 AM
Comment:
Could you please send the source in C# to this e-mail address: americamysweethome@gmail.com

Thanks a lots in advance!

KT
Title: it is giving compilation error   
Name: Suma
Date: 2007-04-18 9:27:26 AM
Comment:
for me it's giving error as writtn below:
'transfervalues.WebForm1.ddl_SelectedIndexChanged(object, System.EventArgs)' is inaccessible due to its protection level

plz give me solution.
"transfervalues" is my virtual directory name.
i named targetpage.aspx to parent file
and i named source.aspx to child file
an you plx suggest me why i am getting this error?
Title: Return Value from Pop Up Window to Master Content Page.   
Name: Gaurava Arya
Date: 2007-04-18 1:54:45 AM
Comment:
I need solution for it. help meeeeee......
I have one Master Page, one Master Content Page(Default.aspx) and one aspx page(Default2.aspx) for Pop Up Window. In the Default Page I placed TextBox and LinkButton. In the Default2.aspx, i placed Calendar Control. When i click Linkbutton, it will open Default2.aspx as pop up window. now i selected date from Calendar control. then pop up window should be closed and the selected date is displayed on the TextBox.

I am able to Open the pop up window from Master Content Page. But when i select Date...not returning the value to the TextBox..Please Tell me how to refer the Controls exist in the Content Page. and how to return the value to the Content Page.

What's the Exact Solution....Somebody help me
It will work successfull without Master Page.

my mail id: gauravkumararya@gmail.com
Title: pop up calendar wont work with a textbox in gridview   
Name: HM
Date: 2007-04-02 4:24:59 AM
Comment:
Somebody please help have been struggling with this for a week. Javascript cant seem to pass back value to a textbox within a gridview. If the textbox is outside the gridview it works fine..
Title: Calendar Popup loads Ok, but there is a problem   
Name: SHB
Date: 2007-03-30 11:39:53 AM
Comment:
When using the Calendar Popup in a content page of a masterpage the strForName is always set to aspnetForm
This breaks this line from working properly
window.opener.document.forms["<%= strFormName %>"]......

How can I fix this?
Title: C# Code   
Name: Hawk
Date: 2007-03-24 10:43:36 AM
Comment:
IS THERE ANY C# CODE FOR THIS
Title: Master Page detailview templated field   
Name: chrs
Date: 2007-03-14 4:15:06 PM
Comment:
I have a detailsview in a form1.
From the detailview a templated field and the calendar call.
The return of the datevalue stops with an error:
'window.opener.document.forms.form2.elements.TextBox1' is empty or no object.
The call is made from the detailsview.
Can somebody help?
Title: Pop Calendar   
Name: Shalini Agrawal
Date: 2007-03-13 5:54:46 AM
Comment:
Code is very good but needed in C#.Still i can get an overview
Title: Need in C#   
Name: Ritesh S. Gadodia
Date: 2007-03-12 2:19:44 AM
Comment:
u have design goog code but i need in C#
Title: Master Page problem   
Name: Therfar
Date: 2007-03-06 1:59:32 PM
Comment:
I have figured the way to make it compatible with asp.net 2.0 master page, read it at the url above
Title: PopUp Calendar - Part 2   
Name: sscoder
Date: 2007-02-23 11:39:59 AM
Comment:
Forgot to mention that I'm using a formView for adding data from a form to SQL. Don't know if that would make a difference.
Title: PopUp Calendar   
Name: sscoder
Date: 2007-02-23 11:37:35 AM
Comment:
Very good tutorial! I'm trying to add it to my form. One problem. When I click a date and click on select it doesn't close the window and place the date on the form. I copied everything from the parent and popup child files you provided. What am I doing wrong?
Title: Popup Calender   
Name: Suneel
Date: 2007-02-17 1:22:28 AM
Comment:
Im very happy seeing this.But can u please write the JavaScript also sothat the viewers can comfort free.
Title: Good   
Name: Vimal
Date: 2007-02-16 2:33:43 AM
Comment:
Ya its really good. i got good idea from it
Title: Click on a Date   
Name: Sanjeewa Kalupahana
Date: 2007-02-13 12:48:02 PM
Comment:
Hi,

One of the steps missing of my solutions. Please not the steps as follows.

I would like to add the following tip to close the calendar once the user click on the day he prefer.

1.) Add a public string variable e.g. GetDateScriptCall in the code behind of the calendar.

2.) In the myCalendar_SelectionChanged event. Set it's value as GetDateScriptCall = "&lt;script language='javascript'&lt;ReturnDate();&gt;/script&gt;" after the assignment of the selected date.

3.) In the ASPX HTML source view of the Calendar.aspx page. Add the String Variable GetDateScriptCall within the body tag. as

&lt;body&gt;...
&lt;%= GetDateScriptCall %&gt;

4.) Now you want need any of the buttons in the Calendar.aspx page.
Title: PopUp Calender   
Name: ath
Date: 2007-02-13 3:53:03 AM
Comment:
It will really help me a lot.I'll use it after a slight modifaiction..i.e I'll remove select & Close button and user will be able to select & use date directly by clicking date in the calender.I guess It will become more user friendly then
Many Thanxxxx
Title: thank u very much   
Name: Arshi & Pinakin
Date: 2007-02-07 7:26:29 AM
Comment:
Thank u very much. i m too much happy when i got this code
Title: Thanks a lot......................   
Name: Pinakin Patel(P.K)
Date: 2007-02-07 6:04:26 AM
Comment:
Thank u very much. This demo help me lot. i got that which i want from too many days.
Title: Closing the Calendar when Date is Selected   
Name: Sanjeewa Kalupahana
Date: 2007-02-02 12:25:14 AM
Comment:
Hi,

This is excellent!! Like to thank you Colt Kwong!

I would like to add the following tip to close the calendar once the user click on the day he prefer.

1.) Add a public string variable e.g. GetDateScriptCall in the code behind of the calendar.

2.) In the myCalendar_SelectionChanged event. Set it's value as GetDateScriptCall = "&lt;script language='javascript'&gt;ReturnDate();&lt;/script&gt;" after the assignment of the selected date.

3.) Now you want need any of the buttons in the Calendar.aspx page.
Title: Length of voice file   
Name: Hare Krishna
Date: 2007-01-20 2:29:01 AM
Comment:
Hi,
I want code of voice length count as like hh:mm:ss for example if any song length of 5:25(mm:ss) and also want calender PopUp code in C#.
so if you have code in c# then please send krishna_bca3@yahoo.com

Thanks a lot
Title: PopUp Calendar   
Name: Hare Krishna
Date: 2007-01-20 2:18:46 AM
Comment:
Do you have a example code on calendar page that do not have select and close button on it. when select a date and time, the date pass to the parent page without click on the select button and current time pass by default to the parent page without click.

Thanks
Title: drop down list using pop calender   
Name: meisong
Date: 2007-01-04 10:52:05 PM
Comment:
tanks for your information about this tutorial, but iwant now
how make drop down list using popup calender,
tanku b for
Title: popupcalendar   
Name: newasp
Date: 2006-12-28 1:34:02 PM
Comment:
it helps me a lot, and i just want to say...THANK YOU!!!
Title: DtP   
Name: Rajeesh
Date: 2006-12-26 3:43:37 AM
Comment:
its very useful ....and i got it in the exact time
regards
rajeesh
Title: popup ques   
Name: Roxanne
Date: 2006-12-20 11:17:29 AM
Comment:
I am trying to ativate a button on the opener pg when the date is selected on the calendar pg and is sent bk to the opener. Another button on the opener shoudl atuomaticaly be enabled. (when the opener loads the button is currently disabled)
please advise
Title: help for Return Value from Pop Up Window from Master Content Page   
Name: Aaryan
Date: 2006-12-20 2:38:06 AM
Comment:
Hi LX....the solution u have given is working well with window.open as pop up window...but when i'm using window.showModalDialog...it's not returning the value to Master Content Page...it's opening a window with url: javascript:_doPostBack('Calendar1','2345')

Any ideas...plz tell me..

Thanks
Aaryan
Title: help for Return Value from Pop Up Window from Master Content Page   
Name: Aaryan
Date: 2006-12-19 10:39:15 AM
Comment:
Hi LX..

I'm so much thankful to you. This works well..You said, u have problem with the calendar pops up in frount of all other controls but drop downs. i didn't get you what u said....

Well..i am using two DropDownLists for selectin Month and Year and one Calendar contorl.. working succefully.

Thanks.
Aaryan
Title: help for Return Value from Pop Up Window from Master Page (with user control)   
Name: LX
Date: 2006-12-18 4:51:42 PM
Comment:
This information may help these people who commented before: Gopi, Pat, Aaryan

The Master Page has Place holders...
asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server"

The actual page which uses the master page has Content ...
asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"

But the HTML page generated by the ASP.net places the STUFF from the asp:Content into the asp:ContentPlaceHolder.
It also renames your form name to "aspnetForm" ignoring what ever you called the master page form.

IN VB.net you use the ClientID to name the control you are using...
sName = "document.aspnetForm." + txtStartDate.ClientID + ".value = '01/09/2006'; "

In java script the results would look like this...
document.aspnetForm.ctl00_ContentPlaceHolder2_Uc_blk_core1_txtStartDate.value = '01/09/2006';
Or like this (they both work)...
document.aspnetForm.ctl00$ContentPlaceHolder2$Uc_blk_core1$txtEndDate.value = '01/09/2006';

My txtStartDate was in a user control "Uc_blk_core" named "Uc_blk_core1" on the form in the "ContentPlaceHolder2" Content Place Holder in the "ctl00" object on the master page "aspnetForm".

My problem is that the calendar pops up in frount of all other controls but drop downs. So I have drop down listboxes displayed on top of my calendar!
Title: popup calendar   
Name: Roxanne
Date: 2006-12-18 3:37:59 PM
Comment:
This has heped me more than nething i have found so far! i had been struggling with this problem fro more than a week n now its done! thank you!
Title: Return Value from Pop Up Window to Master Content Page.   
Name: Aaryan
Date: 2006-12-18 9:28:14 AM
Comment:
I need Help!!!!!!!!!. No one is giving the Solution for it.

I have one Master Page, one Master Content Page(Default.aspx) and one aspx page(Default2.aspx) for Pop Up Window. In the Default Page I placed TextBox and LinkButton. In the Default2.aspx, i placed Calendar Control. When i click Linkbutton, it will open Default2.aspx as pop up window. now i selected date from Calendar control. then pop up window should be closed and the selected date is displayed on the TextBox.

I am able to Open the pop up window from Master Content Page. But when i select Date...not returning the value to the TextBox..Please Tell me how to refer the Controls exist in the Content Page. and how to return the value to the Content Page.

What's the Exact Solution....Somebody help me
It will work successfull without Master Page.

my mail id: anweshkumar@gmail.com
Title: VS 2005   
Name: Pat
Date: 2006-12-12 3:03:02 PM
Comment:
Did someone find out how to reference the Parent form's name? document.forms(0).name returns 'aspnetForm'.

And if using masterpages someone had suggested referencing the parent's control as Ctl00$Main$txtStartDate, where "Main" is the contentholder ID. This doesn't seem to work either. Any ideas?
Title: Calendar   
Name: Erik
Date: 2006-11-21 1:54:44 PM
Comment:
Nice example, translated it to c# and it works perfect.
Title: Thanks a lot for your calendar!   
Name: anna
Date: 2006-11-19 9:13:18 PM
Comment:
im new to asp.net, and was trying to add popup calendar,,
I really appreciate your sample calendar, helped me a lot!!
Thanks!
Title: Form parameter passing problem   
Name: Gopi
Date: 2006-11-14 2:52:14 AM
Comment:
I am using Asp.Net 2.0 Version- and using Master Pages for the webforms.

And passing the Form parameter is a problem.I am getting the form name as "aspnetForm" when i try to print that form name in alert box, can u suggest the solution for that
Title: When Using Master Pages   
Name: Nagendra
Date: 2006-11-03 7:42:44 AM
Comment:
Hi Colt Kwong,

I am using Asp.Net 2.0 Version- and using Master Pages for the webforms.

And passing the Form parameter is a problem, can u suggest the solution for that
Title: setfocus   
Name: Ramakrishnan
Date: 2006-11-01 2:36:45 AM
Comment:
hi,
can u please send the piece code for how to give the set focus to the parent page after closing the child window.


regds
ramakrishanan
Title: Still No GridView or DetailsView Version?   
Name: KevMull
Date: 2006-10-21 1:26:12 PM
Comment:
Author, any chance of a more 'modern' up to date version to cope with today's ever increasing use of GridVies and DetailsView?

Godd work btw
Title: A very nice example   
Name: Nic
Date: 2006-09-21 1:27:04 PM
Comment:
Hi ,

This is a very easy and a nice example which anybody can understand.I am new to .Net programming.I was able to change the code to C# and it works very nicely.I am planning to add some more extra features to it.....
Title: how does it work for conntent page   
Name: cougar
Date: 2006-09-20 9:31:09 AM
Comment:
HI,
I too have been trying to use the calender control on a content page, but couldnt get it to work. Does somebody have an idea how to make it work.
Thanks in advance
Title: does it work for contentpages   
Name: riyaz chowdhary
Date: 2006-09-12 2:57:20 AM
Comment:
hi,
i hve tried this for masterpaes & contentpages..it does not work.can you please specify how it will work for contenpages.
Title: Improvement Plz   
Name: Lu5ck
Date: 2006-09-11 3:06:31 AM
Comment:
The article is good

But there some point when choosing date via Drop Down is buggy
Title: PopUp Calendar   
Name: Deb
Date: 2006-08-30 8:04:33 PM
Comment:
Thanks for the code. I had been looking for something like it for a long time.
Title: Well done!   
Name: Body Tag
Date: 2006-08-28 12:48:26 PM
Comment:
Thank you kindly for this control it is very easily implemented and has probley saved me a few days coding!...
Title: calander   
Name: cal
Date: 2006-08-23 5:11:15 AM
Comment:
please sent me calender code
Title: Does this one work for ASP.Net 2.0   
Name: kaka
Date: 2006-08-18 2:52:15 AM
Comment:
I am using VS2005, VB.NET, ASP.Net2.0. Does this code work for 2.0? Thanks
Title: Popup Calendar won't work in datagrid or gridview   
Name: Evan A. Bonnett
Date: 2006-08-09 6:56:38 AM
Comment:
The popup wont work in the GridView or DataGrid because of the way controls that implement INamingContainer work. The control that you place in the EditItemTemplate are renamed something unique so that control names don't repeat (e.g. gvPerson_ctl03_ctl05_txtDate). You can get this unique name by accessing the ClientID property of the control. However, I am trying to get this to work and have not found out where to hook in yet.
Title: Nice work!   
Name: Jackson
Date: 2006-08-08 2:54:12 PM
Comment:
Thanks for the article!
How about adding all the comments to the main article, so it'll be easier to understand? Took me a while to figure out how to make this work in a master page environment, even though it's written down here somewhere.

Thanks again!
Title: No need for CheckWindow()   
Name: Noel
Date: 2006-07-20 7:45:04 AM
Comment:
as described at :http://www.webreference.com/js/tutorial1/opener.html

a more elegant way of handling the parent window getting closed is like this..

if (window.opener && !window.opener.closed)
{
// return value
}
Title: PopUp Calendar   
Name: Indraa
Date: 2006-07-12 2:15:32 PM
Comment:
Great work!! and no words to tell your greatness...
Title: popup calender   
Name: srinivas
Date: 2006-07-04 6:20:54 AM
Comment:
thanks a lot for providing me such a vakuable information.
Title: SURFThru.com   
Name: Patrick
Date: 2006-06-27 1:35:30 PM
Comment:
I used Infragistics to do this same function, but using MS only is a pain. Your example is excellent.
Title: Demo Doesnt Work VS.Net 2003   
Name: Raajiv
Date: 2006-05-16 10:31:59 AM
Comment:
ReturnDate Function which was return in javascript doesn't work in Visual Studio.Net 2003 with VB.
window.opener.document.forms["<%= strFormName %>"].elements["<%= strCtrlName %>"].value = "<%= strSelectedDate %>";

Pls Suggest Any Solution If You Can!!!!
Title: Demo Doent Work   
Name: Raajiv
Date: 2006-05-16 8:52:08 AM
Comment:
ReturnDate Function which was return in javascript doesn't work in Visual Studio.Net 2003 with VB.
window.opener.document.forms["<%= strFormName %>"].elements["<%= strCtrlName %>"].value = "<%= strSelectedDate %>";

Pls Suggest Any Solution If You Can!!!!
Title: Thanks   
Name: G.Vijayakumar
Date: 2006-05-16 8:00:17 AM
Comment:
It is working fine.Thanks lot.
Title: Popup Calendar won't work in datagrid or gridview   
Name: nrk
Date: 2006-05-11 4:11:58 AM
Comment:
aay,

This web couldn't allow me to paste my code through this comment. There are some kind of errors when putting symbol like < , >. I don't know why!


Here, What I've found is the Popupcalendar work great only on simple webpage but won't work when putting it in datagrid or gridview. I inserted gridview on new webpage and create EditItemTemplate for updating OrderedDate by using PopupCalendar. I'm trying to edit the date field using popupcalendar INSIDE gridview manytimes but nothing happen. Do you have any idea what goes wrong?

Please don't give up on me.
Title: RE: aay   
Name: Colt
Date: 2006-05-10 9:19:17 PM
Comment:
Can you provide more information about your situation?
Pls see: http://authors.aspalliance.com/Colt/Articles/PopUpCalendar.aspx
Title: aay   
Name: aay
Date: 2006-05-10 1:20:45 PM
Comment:
Can you give me working code and tell me how to work with

thanks
Title: aay   
Name: aay
Date: 2006-05-10 1:19:49 PM
Comment:
I tried to copy and past your code it gives me error page canot found
Title: PoupUp Calendar within DetailsView instead (2)   
Name: nrk
Date: 2006-05-08 2:11:55 AM
Comment:
Note: I use '(' and ')' instead of '<' , '>' respectively;

(body onunload="CheckWindow();")
(form id="form1" runat="server")
(asp:DetailsView ID="DetailsView1" runat="server" )
(InsertItemTemplate>
(asp:TextBox ID="TextBox1" runat="server")(/asp:TextBox)
(a href="javascript:GetDate('TextBox1')")(img alt="PopUp Calendar" src="../Images/SmallCalendar.gif" border="0" /)(/a)

(/InsertItemTemplate)
(/asp:DetailsView)
Title: PoupUp Calendar within DetailsView instead   
Name: nrk
Date: 2006-05-08 2:00:02 AM
Comment:
Please help me here!

If there is textbox1 having popupcalendar control in detailsview which is part of form1 instead. Because it won't allow inserting chosen date through textbox1 in detailsview as described below, how do I need to change any part of source code? I'm really appreciated and thank for your time.
Title: Too good   
Name: Vivek Phadke
Date: 2006-05-01 10:25:59 AM
Comment:
too good boss...
this is really nice calendar control.
Title: PopUp Calendar   
Name: kvreddy
Date: 2006-04-03 4:46:48 PM
Comment:
its nice article, its helped me a lot, Thanks
kvreddy
Title: URGENT- HELP   
Name: Rahul
Date: 2006-03-22 5:38:41 AM
Comment:
How do I name parent windoe (i.e.)
Parent Window --> PopUP Calendar.aspx
Child Window --> Calendar.aspx
It is not working for me--

Please help me!

Thanks in advance,
Rahul
Title: PopUp Calender   
Name: DJEL
Date: 2006-03-16 7:23:55 AM
Comment:
Great solution (can be included in my C# solution without changing any line of code).

Saves me a lot of time !
Title: m   
Name: zyntix
Date: 2006-03-10 5:00:23 AM
Comment:
That's good idea.
Thanks a lot. ;)
Title: PopUp Calendar   
Name: laxman
Date: 2006-03-10 1:46:15 AM
Comment:
we need C# code
Title: Huub   
Name: Huub
Date: 2006-03-09 5:14:22 PM
Comment:
I can't make the windows.opener work in the ReturnDate within a Visual Web developer site. Any suggestions ?
Title: RE: Demo   
Name: Colt
Date: 2006-02-27 10:44:18 PM
Comment:
>> your demo doesn't work

Fixed! Thanks for your information.

Regards,
Colt
Title: demo   
Name: no thanks
Date: 2006-02-27 2:28:18 PM
Comment:
your demo doesn't work
Title: Problem   
Name: Morten
Date: 2006-02-03 3:42:01 AM
Comment:
The Demo doesn't work when I try it.

And if I copy the source code from parent, and save it as calendar.asp and copy the pop up child into calendarchild.asp is doesn't work. Could you write how to get it to work?.
Thanks.

p.s. yes i know I'm new to this....
Title: RE: PopUp Calendar   
Name: Colt
Date: 2006-01-12 5:53:06 AM
Comment:
>> but rather on a user control
You can use the same technique as inside a MasterPage, that is, pass the ClientID of the TextBox to the parent page, maybe the ClientID is a bit strange compared with normal TextBox, it is because the ClientID is prefixed with the parent control. Good luck.
Title: PopUp Calendar   
Name: Jared
Date: 2006-01-12 4:42:12 AM
Comment:
Nice simple example that works well. But my problem is that I do not have my textbox on a webform, but rather on a user control. How would I go about specifying the textbox?
Title: CSharp version   
Name: quanou
Date: 2005-12-27 12:44:48 PM
Comment:
OK, I figured it out.
No theme, exception otherwise.
And if you use a masterpage, the control name as argument is :
Ctl00$Main$txtStartDate, where "Main" is the contentholder ID.
Title: Syntax ?   
Name: quanou
Date: 2005-12-26 7:24:47 PM
Comment:
Hi,
I am using visual web developer 2005 express edition and C#.
"<%= strSelectedDate %>" doesn't work (provokes an exception), so I used this syntax "<%# strSelectedDate %>" but w/ no success :

window.opener.document.forms["<%# strFormName %>"].elements["<%# strCtrlName %>"].value = "<%# strSelectedDate %>";

It seems like the instance variables can't be solved. So, as a Javascript beginner, i guess that it's not the right syntax, but i can't figure it out.

Please help.
Title: Web programmer   
Name: Suparuek P
Date: 2005-12-17 12:31:50 AM
Comment:
very good, this is exactly example that i'm looking for
Title: P[OPUP CALENDER   
Name: SKP BR
Date: 2005-12-05 8:14:51 AM
Comment:
A VERY HELPFUL TOOL.
THANKS
Title: Popup Calenser   
Name: Indu
Date: 2005-11-29 3:11:27 PM
Comment:
It helped me a lot......
very useful and...very pretty code...


Thank u..
Indu
Title: Pop up   
Name: Md
Date: 2005-11-22 2:47:31 PM
Comment:
hey Thanks!!
Title: Fantastic Calendar   
Name: Ashiq
Date: 2005-11-12 1:19:33 PM
Comment:
Hi,
The calendar looks nice it helped me a lot.Thanks for this tutorial.
Title: RE: PopUp Calendar   
Name: Colt Kwong
Date: 2005-09-19 9:34:15 PM
Comment:
>> Do you have a example code on calendar page that do not have select and close button on it. when sel
ect a date, the date pass to the parent page without click on the select button.

FYI: http://aspnet.4guysfromrolla.com/articles/030202-1.aspx
Title: PopUp Calendar   
Name: xc
Date: 2005-09-19 12:14:56 PM
Comment:
Do you have a example code on calendar page that do not have select and close button on it. when select a date, the date pass to the parent page without click on the select button.

Thanks.
Title: Great Tutorial   
Name: Khalid
Date: 2005-09-04 2:12:48 AM
Comment:
hi Colt, thx a lot for the tutorial,
t helped me alot!
i have converted it to C#, and i shall be posting the new code shortly as soon as i am done with my project!
the only problem i faced was passing the form name in the query string, yet i hard coded it!
there should be a way to pass it by ID, yet i do not have the time for it, once i refine it, i will be posting it.
meanwhile, if anyone is interested in the C# version, email me at khsaeed@rmit.edu.au
cheers!
Title: PopUp Calendar   
Name: Roopa
Date: 2005-08-29 8:32:18 AM
Comment:
hi
This is a pretty useful code..
but my problem is i need to pass the date to the textbox as how u did,but the textbox shouldnt be on the aspx page but in ascx.Is there any method to pass the values from the calender to the textbox in an ascx.
Title: PopUp Calendar   
Name: Vidya
Date: 2005-08-16 11:13:31 PM
Comment:
This was really useful for me . thks a lot
Title: PopUp Calendar   
Name: AJ
Date: 2005-08-02 6:15:06 AM
Comment:
Hi Lisa,
This is what exactly I need. I wish not to have Select and Close buttons and as soon as date is selected the it should close.

Please send me the code at ajaymahilani@hotmail.com
Title: Popup Calender   
Name: Raghu
Date: 2005-06-20 7:14:35 PM
Comment:
Good Article
Title: Popup Calendar   
Name: Annie
Date: 2005-06-09 2:29:44 AM
Comment:
Thanks for the calendar, exactly what I'm looking for.
I just need to change the year to display more values for DOB field.
Title: Calendar   
Name: Guillermo Mejia
Date: 2005-05-11 5:33:46 PM
Comment:
thank you very much!!! exactly what i was looking for
Title: mr.   
Name: zonayed
Date: 2005-05-05 5:04:24 AM
Comment:
can you have the same code for c#.
i need to create the same things on c#.
any help pls?

thanks
Title: thank!   
Name: hanihuman
Date: 2005-04-21 10:54:36 PM
Comment:
thank for your calendar
Title: PopUp calendar   
Name: kim
Date: 2005-04-21 3:41:06 AM
Comment:
It won't work on me, it seems like when i go back to the opener, the control was gone in the opener,,,,, so I ran "window.opener.document.write("something")" instead of "window.opener.document.forms["<%=strFormName%>"}.elements["<%=strCtrlName%.]", the opener page only display: something....would you please help me?
Title: PopUp Calendar   
Name: Rex
Date: 2005-04-20 12:26:32 PM
Comment:
Lisa,
Could you please share your code
thanks a lot
Title: PopUp Calendar   
Name: kiki
Date: 2005-04-18 2:36:03 AM
Comment:
Colt Kwong, Great tutorial...it helps me too, thanks!

Lisa, will u share with us how u can do that?thx
Title: Bug in Your demo & code   
Name: Lisa
Date: 2005-04-15 3:37:43 PM
Comment:
I really liked this calendar tutorial - I even improved on it by not having to click select, and also using the date entered in the text box to open the calendar to the selected month/year --> ensuring that the month/year are valid and in the drop down lists...
Title: PopUp Calendar   
Name: Mirror
Date: 2005-03-12 8:54:13 AM
Comment:
It helps me a lot~ thanks~

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-05-23 2:51:44 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search