I have an image I use to popup a new window. I have an onclick event for this image which calls the following
js function:
<script language="javascript">
<!--
function PopUp(textbox)
{
window.open('datepicker_calendar.aspx?Date=' + '6/8/2004' + '&ControlID=' + textbox,'DatePickerWindow','width=170,height=165,s tatus=0,resizeable=0,scrollbars=0');
}
-->
</script>
This function passes the textbox form field ID to the popup page and when you select a date on the calendar, it populates the textbox. The code for the popup page looks like this (and most of the code is just formatting of the calendar control):
<HTML>
<HEAD>
<title>Select Date</title>
<script language="javascript">
// this will determine the value and return it to the opening page
function SelectDate(SelectedDate)
{
var textboxid = document.Form1.hdnID.value;
window.opener.document.Form1.elements[textboxid].value = SelectedDate;
self.close();
}
</script>
</HEAD>
<body topmargin=0 leftmargin=0>
<form id="Form1" method="post" runat="server">
<asp:calendar id="Calendar1" runat="server" OnVisibleMonthChanged="month_click" OnDayRender="Calendar1_DayRender"
bordercolor="#3366CC" Width="170px" Height="160px" Font-Size="8pt" BorderWidth="1px" BackColor="White"
DayNameFormat="FirstLetter" ForeColor="#003399" Font-Names="Verdana" CellPadding="1">
<TodayDayStyle ForeColor="White" BackColor="#99CCCC"></TodayDayStyle>
<SelectorStyle ForeColor="#336666" BackColor="#99CCCC"></SelectorStyle>
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF"></NextPrevStyle>
<DayHeaderStyle Height="1px" ForeColor="#336666" BackColor="#99CCCC"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedDayStyle>
<TitleStyle Font-Size="10pt" Font-Bold="True" Height="25px" BorderWidth="1px" ForeColor="#CCCCFF"
BorderStyle="Solid" BorderColor="#3366CC" BackColor="#003399"></TitleStyle>
<WeekendDayStyle BackColor="#CCCCFF"></WeekendDayStyle>
<OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
</asp:calendar><INPUT id="hdnID" type="hidden" value="<%=Request.QueryString["ControlID"]%>">
</form>
</body>
</HTML>
Hope that helps