首页 技术 正文
技术 2022年11月12日
0 收藏 781 点赞 2,614 浏览 2539 个字

原文地址:asp.net 弹出式日历控件 选择日期 Calendar控件 作者:逸苡

html代码:

<%@ Page Language="C#" CodeFile="calendar.aspx.cs" Inherits="calendar" %>

<!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 runat="server">

    <title>无标题页</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:Panel ID="Panel1" runat="server" Height="27px" Width="540px">

            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

            &nbsp;&nbsp;&nbsp;

            <asp:Button ID="Button1" runat="server" OnClick="btnOnClick" Text="选择" />

            <div id="LayerCC" style="left: 155px; width: 189px; position: absolute; top: 55px;

                height: 191px; background-color: white" visible="false" runat="server">

                <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#3366CC"

                    BorderWidth="1px" CellPadding="1" Font-Names="Verdana" Font-Size="8pt" ForeColor="#003399"

                    Height="200px" OnSelectionChanged="Calendar1_SelectionChanged" Width="220px">

                    <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />

                    <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />

                    <WeekendDayStyle BackColor="#CCCCFF" />

                    <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />

                    <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>

        </asp:Panel>

    </div>

    </form>

</body>

</html>

参考代码C#部分

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

public partial class calendar : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

}

    protected void btnOnClick(object sender, EventArgs e)

    {

        LayerCC.Visible = !LayerCC.Visible;

}

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)

    {

        TextBox1.Text = Calendar1.SelectedDate.ToString("yyyy-MM-dd");

        LayerCC.Visible = false;

}

}

效果图:

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,960
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,484
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,330
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,113
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,745
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,779