I usually do this.
If the calendar opens in a new window, pass the id of the text box that should be filled with date as a query string to the popup page the that contains the calendar window.
In your popup page that contains the calendar
Add OnSelectionChanged event to your calendar control
<asp:Calendar ID="SiteCalendar" runat="server" BackColor="White" BorderColor="#999999"
CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="Black" Height="180px" Width="200px" OnSelectionChanged="SiteCalendar_SelectionChanged">
In code behind handle the event
public void SiteCalendar_SelectionChanged(object sender, System.EventArgs e)
{
string date = SiteCalendar.SelectedDate.ToString("MM/dd/yyyy");
string script = @"<script language=""javascript"">" +
"\n window.opener." + Request.QueryString["date"] + ".value = '" + date + "'; \n" +
"window.close();" +
"</script>";
//register this as startup script so that it fires and populates the text box
}
If you have the calendar and the textbox on the same page, it is still simpler just do the following
public void SiteCalendar_SelectionChanged(object sender, System.EventArgs e)
{
string date = SiteCalendar.SelectedDate.ToString("MM/dd/yyyy");
txtDate.Text=date; //txtDate is the id of the tetbox that should be filled with date.
}