<%@ Page Language="c#" %> <script runat="server"> void Calendar1_SelectionChanged(Object sender, System.EventArgs e) { string strjscript = "<script language='javascript'>"; strjscript += "window.opener." + HttpContext.Current.Request.QueryString["formname"]; strjscript += ".value = '" + Calendar1.SelectedDate.ToString("d") + "';window.close();"; strjscript += "</script" + ">"; //Don't ask, tool bug. Literal1.Text = strjscript; } void Calendar1_DayRender(Object source, DayRenderEventArgs e) { if (e.Day.Date.ToString("d") == DateTime.Now.ToString("d")) { e.Cell.BackColor = System.Drawing.Color.LightGray; } } </script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Choose a Date</title> </head> <body leftmargin="0" topmargin="0"> <form runat="server"> <asp:Calendar id="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged" OnDayRender="Calendar1_DayRender" showtitle="true" DayNameFormat="FirstTwoLetters" SelectionMode="Day" BackColor="#ffffff" FirstDayOfWeek="Monday" BorderColor="#000000" ForeColor="#00000" Height="60" Width="120"> <TitleStyle backcolor="#000080" forecolor="#ffffff" /> <NextPrevStyle backcolor="#000080" forecolor="#ffffff" /> <OtherMonthDayStyle forecolor="#c0c0c0" /> </asp:Calendar> <asp:Literal id="Literal1" runat="server"></asp:Literal> </form> </body> </html>