⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 组合控件的使用(日期).txt

📁 C# 是创新性的新式编程语言
💻 TXT
字号:
1.
<%@ Page language="c#" Codebehind="WebForm5.aspx.cs" AutoEventWireup="false" Inherits="Co_5.WebForm5" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>WebForm5</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<table style="BORDER-RIGHT:black 1px solid; BORDER-TOP:black 1px solid; BORDER-LEFT:black 1px solid; BORDER-BOTTOM:black 1px solid"
				cellpadding="0" cellspacing="0">
				<tr>
					<td>
						<asp:textbox runat="server" id="txtMonth" columns="2" BorderSize="0" style="BORDER-RIGHT:0px; BORDER-TOP:0px; BORDER-LEFT:0px; BORDER-BOTTOM:0px; FONT-FAMILY:courier new">
						02</asp:textbox>
						-
						<asp:textbox runat="server" id="txtDay" columns="2" maxlength="2" style="BORDER-RIGHT:0px; BORDER-TOP:0px; BORDER-LEFT:0px; BORDER-BOTTOM:0px; FONT-FAMILY:courier new">
						14</asp:textbox>
						-
						<asp:textbox runat="server" id="txtYear" columns="4" maxlength="4" style="BORDER-RIGHT:0px; BORDER-TOP:0px; BORDER-LEFT:0px; BORDER-BOTTOM:0px; FONT-FAMILY:courier new">
2005
					2005</asp:textbox>
					</td>
					<td align="right">
						<asp:linkbutton runat="server" tooltip="Refresh date" font-name="webdings" text=" q " ID="Linkbutton1" />
					</td>
					<td>&nbsp;
					</td>
					<td align="right">
						<asp:linkbutton runat="server" id="lnkShowCalendar" tooltip="Toggle calendar" font-name="webdings"
							text=" 6 " />
					</td>
				</tr>
				<tr>
					<td colspan="6">
						<asp:calendar runat="server" id="myCalendar" Visible="false" BackColor="white" ForeColor="black"
							Font-Name="verdana" Font-Size="9pt" TitleStyle-BackColor="#33ddff" TitleStyle-ForeColor="black"
							TitleStyle-Font-Bold="True" SelectorStyle-BackColor="#99ccff" SelectedDayStyle-BackColor="Navy"
							SelectedDayStyle-Font-Bold="True" DayHeaderStyle-Font-Bold="True" Font-Names="verdana">
							<SelectorStyle BackColor="#99CCFF"></SelectorStyle>
							<DayHeaderStyle Font-Bold="True"></DayHeaderStyle>
							<SelectedDayStyle Font-Bold="True" BackColor="Navy"></SelectedDayStyle>
							<TitleStyle Font-Bold="True" ForeColor="Black" BackColor="#33DDFF"></TitleStyle>
						</asp:calendar>
					</td>
				</tr>
			</table>
		</form>
	</body>
</HTML>
2.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Co_5
{
	/// <summary>
	/// WebForm5 的摘要说明。
	/// </summary>
	public class WebForm5 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox txtMonth;
		protected System.Web.UI.WebControls.TextBox txtDay;
		protected System.Web.UI.WebControls.TextBox txtYear;
		protected System.Web.UI.WebControls.LinkButton Linkbutton1;
		protected System.Web.UI.WebControls.LinkButton lnkShowCalendar;
		protected System.Web.UI.WebControls.Calendar myCalendar;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			txtYear.Text=DateTime.Now.Year.ToString();
			txtMonth.Text=DateTime.Now.Month.ToString();
			txtDay.Text=DateTime.Now.Day.ToString();
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.lnkShowCalendar.Click += new System.EventHandler(this.lnkShowCalendar_Click);
			this.myCalendar.SelectionChanged += new System.EventHandler(this.myCalendar_SelectionChanged);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void lnkShowCalendar_Click(object sender, System.EventArgs e)
		{
			myCalendar.Visible=!myCalendar.Visible;
			if (myCalendar.Visible)
				lnkShowCalendar.Text = " 5 ";
			else
				lnkShowCalendar.Text = " 6 ";
		}

		private void myCalendar_SelectionChanged(object sender, System.EventArgs e)
		{
			DateTime dtNew = myCalendar.SelectedDate;
			txtYear.Text=dtNew.Year.ToString();
			txtMonth.Text=dtNew.Month.ToString();
			txtDay.Text=dtNew.Day.ToString();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -