1、主页面html代码:
日期:<asp:TextBox ID="TBData" runat="server" Width="89px"></asp:TextBox>
<input id="BTData" style="width: 30px" type="button" value="..." οnclick="opendate();" />
<script language="javascript" type="text/javascript">
function opendate()
{
var txtValue=document.getElementById("<%=this.TBData.ClientID %>");
window.open("/pub_wuc/datetime.aspx?textbox="+txtValue.id,"","width=200 height=200");
}
</script>
2、弹出的日历页面
html:
<form id="form1" runat="server">
<div>
///日历控件///
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#3366CC"
BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana"
Font-Size="8pt" ForeColor="#003399" Height="200px" Width="200px" OnSelectionChanged="Calendar1_SelectionChanged">
<SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
<SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
<WeekendDayStyle BackColor="#CCCCFF" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
<DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
<TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True"
Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
</asp:Calendar>
</div>
</form>
.aspx.cs代码:
protected void Calendar1_SelectionChanged(object sender, EventArgs e)日历的选择事件
{
string returnvalue = this.Calendar1.SelectedDate.ToShortDateString();
string script = "<script>";
script += "window.opener.document.all." + Request["textbox"] + ".value='" + returnvalue + "';";
script += "window.close();";
script += "</script>";
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", script);///程序中注册的JS脚本///
}