Using Calendar as a popup

  • Thread starter Thread starter Merex
  • Start date Start date
M

Merex

Hello all,

I want to use the Calendar control as a popup window. I would like
each day's link to execute some javascript which would set the value
of a textbox on the window which opened the calendar and then close
the calendar window. So basically I want to customize the <A> tag for
each date to call my custom JavaScript function.

function SelectedDate(strDate) {
window.opener.document.forms["frmMain"].elements["txtDate"].value =
strDate;
}

Can anyone point me in the right direction. I am thinking that I
might be able to hook into some event that the calendar generates...

Thanks,
Ross
 
Merex,

I'm not certain if you can easily hook this up to the calendar itself so
that it all executes client side. How about using the body tag a server
control and placing your script into its onload event. Doing so would
require that the calendar post back when a value is selected but it would
then function exactly as you are attempting.

If you decide to go this route I have some sample code in the code library
of my site, www.aboutfortunate.com, that shows how to use the body tag as a
server control. Just search the code library for: "use the body tag as a
server control" or something similar.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Hi

Check out this may help you.

http://www.excentricsworld.com/customcontrols.aspx?id=7

Ravikanth[MVP]

-----Original Message-----
Hello all,

I want to use the Calendar control as a popup window. I would like
each day's link to execute some javascript which would set the value
of a textbox on the window which opened the calendar and then close
the calendar window. So basically I want to customize
the said:
each date to call my custom JavaScript function.

function SelectedDate(strDate) {
window.opener.document.forms["frmMain"].elements ["txtDate"].value =
strDate;
}

Can anyone point me in the right direction. I am thinking that I
might be able to hook into some event that the calendar generates...

Thanks,
Ross
.
 
Ross,
There was a posting related to this about 3 or 6 weeks
ago. Search for calendar control or popups. The code
sample was posted by savarana from Miscrosoft india, she
has a really good sample code of what you are looking for.
I think she implemented a custom coontrol to do so. If not
I will email again as soon as I find the web link of it.
but if you find it posted again so that we can all have
the link to the sample calendar control..

thanks,
jayuya


-----Original Message-----
Hello all,

I want to use the Calendar control as a popup window. I would like
each day's link to execute some javascript which would set the value
of a textbox on the window which opened the calendar and then close
the calendar window. So basically I want to customize
the said:
each date to call my custom JavaScript function.

function SelectedDate(strDate) {
window.opener.document.forms["frmMain"].elements ["txtDate"].value =
strDate;
}

Can anyone point me in the right direction. I am thinking that I
might be able to hook into some event that the calendar generates...

Thanks,
Ross
.
 
Check out this article ( this was the article mentioned by jayuya)
http://www.microsoft.com/india/msdn/articles/PopupCalendarinASP.aspx
or
www.extremeexperts.com/net/articles (For more articles on .NET)

--
Saravana
Microsoft India Community Star,MC**
www.extremeexperts.com



jayuya said:
Ross,
There was a posting related to this about 3 or 6 weeks
ago. Search for calendar control or popups. The code
sample was posted by savarana from Miscrosoft india, she
has a really good sample code of what you are looking for.
I think she implemented a custom coontrol to do so. If not
I will email again as soon as I find the web link of it.
but if you find it posted again so that we can all have
the link to the sample calendar control..

thanks,
jayuya


-----Original Message-----
Hello all,

I want to use the Calendar control as a popup window. I would like
each day's link to execute some javascript which would set the value
of a textbox on the window which opened the calendar and then close
the calendar window. So basically I want to customize
the said:
each date to call my custom JavaScript function.

function SelectedDate(strDate) {
window.opener.document.forms["frmMain"].elements ["txtDate"].value =
strDate;
}

Can anyone point me in the right direction. I am thinking that I
might be able to hook into some event that the calendar generates...

Thanks,
Ross
.
 
Thanks for all the replys. I made it work not long after posting
this.

protected void onDayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e) {
DateTime dtDate = e.Day.Date;
e.Cell.Controls.Clear();

HtmlAnchor anchor = new HtmlAnchor();
anchor.HRef="Javascript:SelectDate('"+dtDate.ToString("MM/dd/yyyy")+"')";
anchor.InnerHtml = Convert.ToString(dtDate.Day);
e.Cell.Controls.Add(anchor);
}

Thanks,
Ross
 
Back
Top