using
System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CalendarShow : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e)
{
if ( ! IsPostBack)
{
int k = Convert.ToInt32(DateTime.Now.Year);
for ( int i = 1900 ; i <= k; i ++ )
{
DPlist_year.Items.Add(i.ToString());
}
for ( int i = 1 ; i <= 12 ; i ++ )
{
DPlist_month.Items.Add(i.ToString());
}
}
else
{
int year, month, day;
year = Convert.ToInt32(DPlist_year.SelectedItem.ToString());
month = Convert.ToInt32(DPlist_month.SelectedItem.ToString());
day = DateTime.Now.Day;
DateTime querydate = new DateTime(year, month, day);
MyCalendar.VisibleDate = querydate;
}
}
protected void MyCalendar_SelectionChanged(Object sender, System.EventArgs e)
{
Response.Write( " <script language="JavaScript"> " );
Response.Write( " parent.document.getElementById("birthday").value=" " + MyCalendar.SelectedDate.ToShortDateString() + " "; " );
Response.Write( " </script> " );
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CalendarShow : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e)
{
if ( ! IsPostBack)
{
int k = Convert.ToInt32(DateTime.Now.Year);
for ( int i = 1900 ; i <= k; i ++ )
{
DPlist_year.Items.Add(i.ToString());
}
for ( int i = 1 ; i <= 12 ; i ++ )
{
DPlist_month.Items.Add(i.ToString());
}
}
else
{
int year, month, day;
year = Convert.ToInt32(DPlist_year.SelectedItem.ToString());
month = Convert.ToInt32(DPlist_month.SelectedItem.ToString());
day = DateTime.Now.Day;
DateTime querydate = new DateTime(year, month, day);
MyCalendar.VisibleDate = querydate;
}
}
protected void MyCalendar_SelectionChanged(Object sender, System.EventArgs e)
{
Response.Write( " <script language="JavaScript"> " );
Response.Write( " parent.document.getElementById("birthday").value=" " + MyCalendar.SelectedDate.ToShortDateString() + " "; " );
Response.Write( " </script> " );
}
}
<
%@ Page
Language
="C#"
AutoEventWireup
="true"
CodeFile
="CalendarShow.aspx.cs"
Inherits
="CalendarShow"
%
>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head id ="Head1" runat ="server" >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< link href ="style.css" rel ="stylesheet" type ="text/css" />
< title > 出生日期选择 </ title >
< script language ="javascript" src ="Images/popup.js" ></ script >
< SCRIPT ID =clientEventHandlersJS LANGUAGE =javascript>
function cancelcss()
{parent.g_pop.close();}
</SCRIPT >
</ head >
< body >
< form id ="form1" runat ="server" >< table width ="100%" border ="0" >
< tr >
< td > 选择年月 < asp:DropDownList ID ="DPlist_year" runat ="server" AutoPostBack ="True" >
</ asp:DropDownList > 年
< asp:DropDownList ID ="DPlist_month" runat ="server" AutoPostBack ="True" >
</ asp:DropDownList > 月 </ td >
</ tr >
< tr >
< td >< asp:Calendar ID ="MyCalendar" runat ="server" OnSelectionChanged ="MyCalendar_SelectionChanged" Width ="302px" NextMonthText ="下月" NextPrevFormat ="ShortMonth" PrevMonthText ="上月" >
< SelectedDayStyle BackColor ="Yellow" ForeColor ="Red" ></ SelectedDayStyle >
< WeekendDayStyle BackColor ="Info" />
< TodayDayStyle BackColor ="DarkTurquoise" />
< OtherMonthDayStyle BackColor ="#E0E0E0" />
< DayStyle BackColor ="Honeydew" BorderColor ="White" BorderStyle ="None" />
< NextPrevStyle BackColor ="White" BorderColor ="#FFC0C0" />
< DayHeaderStyle BackColor ="LavenderBlush" BorderColor ="White" BorderStyle ="Solid" />
< TitleStyle BackColor ="Honeydew" />
</ asp:Calendar ></ td >
</ tr >
</ table >
</ form >
</ body >
</ html >
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head id ="Head1" runat ="server" >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< link href ="style.css" rel ="stylesheet" type ="text/css" />
< title > 出生日期选择 </ title >
< script language ="javascript" src ="Images/popup.js" ></ script >
< SCRIPT ID =clientEventHandlersJS LANGUAGE =javascript>
function cancelcss()
{parent.g_pop.close();}
</SCRIPT >
</ head >
< body >
< form id ="form1" runat ="server" >< table width ="100%" border ="0" >
< tr >
< td > 选择年月 < asp:DropDownList ID ="DPlist_year" runat ="server" AutoPostBack ="True" >
</ asp:DropDownList > 年
< asp:DropDownList ID ="DPlist_month" runat ="server" AutoPostBack ="True" >
</ asp:DropDownList > 月 </ td >
</ tr >
< tr >
< td >< asp:Calendar ID ="MyCalendar" runat ="server" OnSelectionChanged ="MyCalendar_SelectionChanged" Width ="302px" NextMonthText ="下月" NextPrevFormat ="ShortMonth" PrevMonthText ="上月" >
< SelectedDayStyle BackColor ="Yellow" ForeColor ="Red" ></ SelectedDayStyle >
< WeekendDayStyle BackColor ="Info" />
< TodayDayStyle BackColor ="DarkTurquoise" />
< OtherMonthDayStyle BackColor ="#E0E0E0" />
< DayStyle BackColor ="Honeydew" BorderColor ="White" BorderStyle ="None" />
< NextPrevStyle BackColor ="White" BorderColor ="#FFC0C0" />
< DayHeaderStyle BackColor ="LavenderBlush" BorderColor ="White" BorderStyle ="Solid" />
< TitleStyle BackColor ="Honeydew" />
</ asp:Calendar ></ td >
</ tr >
</ table >
</ form >
</ body >
</ html >