Calendar 日历加上可选择年月的选项。
来源:互联网 发布:安特托2K最新数据 编辑:程序博客网 时间:2024/05/14 15:46
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>
- Calendar 日历加上可选择年月的选项。
- 可选年月的日历
- POJ1008My Calendar两种日历年月日间的转换月份用字符数组表示
- 打印任意年月的日历
- 打印给定年月的日历
- daterangepicker 年月可选择
- WPF 可选择年月及显示格式的DatePicker控件
- Calendar日历的使用
- (Java)打印指定年月的日历
- java 日历显示 读出输入的年月
- JS日历可选择隐藏
- 日历Calendar控件的使用
- Calendar日历选择器的使用方法
- 日历控件Calendar的使用
- java的Calendar(日历)类
- java的Calendar(日历)类
- java日历的使用(Calendar)
- Calendar 日历类的使用方法
- 浅谈C中的malloc和free
- 输入一个1~9位的数字,打印中文,注意特殊情况
- 轻量级开发的成功秘诀,第 2 部分: 如何减轻容器
- 动易网站首页调用动网论坛最新帖子列表的操作方法
- 英文谚语大全
- Calendar 日历加上可选择年月的选项。
- VB Net To C Sharp Converter v2.16
- C++ 双向链表类
- 九溪游了一圈
- oracle的复杂聚合函数
- VMware.Workstation.v6.0.3.80004.Incl.Keymaker-EMBRACE
- 提取汉字方法
- Spring中bean的基本xml配置
- Javascript操作Select和Option