弹出日历窗口选择日期

 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脚本///
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值