在ASP.NET中實(shí)現(xiàn)彈出日歷的具體方法
更新時(shí)間:2013年07月23日 10:54:36 作者:
這篇文章介紹了ASP.NET彈出日歷功能的實(shí)現(xiàn)方法,有需要的朋友可以參考一下
ctlCalendar.ascx的源代碼:
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="ctlCalendar.ascx.cs" Inherits="calendar.ctlCalendar" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" enableViewState="True"%>
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
<input type="button" id="Button1" runat="server" value="..."><br>
<asp:Panel id="pnlCalendar" runat="server" style="POSITION: absolute">
<asp:calendar id="Calendar1" runat="server" FirstDayOfWeek="Monday" ShowGridLines="True" BackColor="White"
DayNameFormat="Full" ForeColor="Black" Font-Size="8pt" Font-Names="Verdana" BorderColor="#999999"
CellPadding="4" Width="200px" Height="180px">
<TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle>
<SelectorStyle BackColor="#CCCCCC"></SelectorStyle>
<DayStyle Wrap="False" BorderStyle="Dashed"></DayStyle>
<NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle>
<DayHeaderStyle Font-Size="X-Small" Font-Names="宋體" Wrap="False" BorderStyle="Dashed" BackColor="#CCCCCC"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666"></SelectedDayStyle>
<TitleStyle Font-Size="Small" Font-Bold="True" BorderStyle="Solid" BorderColor="Black" BackColor="#999999"></TitleStyle>
<WeekendDayStyle BackColor="LightSteelBlue"></WeekendDayStyle>
<OtherMonthDayStyle ForeColor="Gray"></OtherMonthDayStyle>
</asp:calendar>
</asp:Panel>
ctlCalendar.ascx.cs的源代碼:
namespace calendar
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// ctlCalendar 的摘要說明。
/// </summary>
public class ctlCalendar : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Panel pnlCalendar;
protected System.Web.UI.HtmlControls.HtmlInputButton Button1;
protected System.Web.UI.WebControls.Calendar Calendar1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
if (!Page.IsPostBack)
{
this.TextBox1.Text = System.DateTime.Now.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute");
}
else
{
string id = Page.Request.Form["__EVENTTARGET"].Substring(0,Page.Request.Form["__EVENTTARGET"].IndexOf(":"));
if (id != this.ID)
{
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute");
}
else
{
this.pnlCalendar.Attributes.Add("style","POSITION: absolute");
}
}
Page.RegisterClientScriptBlock("Script_Panel" + this.ID,
"<script> function On"+this.ID+"Click() { if("+this.ID+
"_pnlCalendar.style.display == "none") "+this.ID+
"_pnlCalendar.style.display = ""; else "+this.ID+
"_pnlCalendar.style.display = "none"; } </script>");
this.Button1.Attributes.Add("OnClick","On"+this.ID+"Click()");
}
#region Web 窗體設(shè)計(jì)器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計(jì)器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器
/// 修改此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
#region 日歷選擇時(shí)的事件
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
this.TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute");
}
#endregion
}
}
復(fù)制代碼 代碼如下:
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="ctlCalendar.ascx.cs" Inherits="calendar.ctlCalendar" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" enableViewState="True"%>
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
<input type="button" id="Button1" runat="server" value="..."><br>
<asp:Panel id="pnlCalendar" runat="server" style="POSITION: absolute">
<asp:calendar id="Calendar1" runat="server" FirstDayOfWeek="Monday" ShowGridLines="True" BackColor="White"
DayNameFormat="Full" ForeColor="Black" Font-Size="8pt" Font-Names="Verdana" BorderColor="#999999"
CellPadding="4" Width="200px" Height="180px">
<TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle>
<SelectorStyle BackColor="#CCCCCC"></SelectorStyle>
<DayStyle Wrap="False" BorderStyle="Dashed"></DayStyle>
<NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle>
<DayHeaderStyle Font-Size="X-Small" Font-Names="宋體" Wrap="False" BorderStyle="Dashed" BackColor="#CCCCCC"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666"></SelectedDayStyle>
<TitleStyle Font-Size="Small" Font-Bold="True" BorderStyle="Solid" BorderColor="Black" BackColor="#999999"></TitleStyle>
<WeekendDayStyle BackColor="LightSteelBlue"></WeekendDayStyle>
<OtherMonthDayStyle ForeColor="Gray"></OtherMonthDayStyle>
</asp:calendar>
</asp:Panel>
ctlCalendar.ascx.cs的源代碼:
復(fù)制代碼 代碼如下:
namespace calendar
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// ctlCalendar 的摘要說明。
/// </summary>
public class ctlCalendar : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Panel pnlCalendar;
protected System.Web.UI.HtmlControls.HtmlInputButton Button1;
protected System.Web.UI.WebControls.Calendar Calendar1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
if (!Page.IsPostBack)
{
this.TextBox1.Text = System.DateTime.Now.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute");
}
else
{
string id = Page.Request.Form["__EVENTTARGET"].Substring(0,Page.Request.Form["__EVENTTARGET"].IndexOf(":"));
if (id != this.ID)
{
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute");
}
else
{
this.pnlCalendar.Attributes.Add("style","POSITION: absolute");
}
}
Page.RegisterClientScriptBlock("Script_Panel" + this.ID,
"<script> function On"+this.ID+"Click() { if("+this.ID+
"_pnlCalendar.style.display == "none") "+this.ID+
"_pnlCalendar.style.display = ""; else "+this.ID+
"_pnlCalendar.style.display = "none"; } </script>");
this.Button1.Attributes.Add("OnClick","On"+this.ID+"Click()");
}
#region Web 窗體設(shè)計(jì)器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計(jì)器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器
/// 修改此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
#region 日歷選擇時(shí)的事件
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
this.TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION: absolute");
}
#endregion
}
}
您可能感興趣的文章:
- ASP.NET Calendar日歷(日期)控件使用方法
- asp.net中日歷函數(shù)Calendar的使用方法
- ASP.NET中為TextBox中添加calendar.js示例代碼
- ASP.NET中實(shí)現(xiàn)彈出日歷示例
- ASP.NET中日歷控件和JS版日歷控件的使用方法(第5節(jié))
- ASP.NET技巧:為Blog打造個(gè)性日歷
- ASP.NET如何獲取兩個(gè)日期之間的天數(shù)
- asp.net 時(shí)間類 一周的周一和周末的日期
- asp.net 日期函數(shù) 某月的第一天和最后一天的日期
- Asp.net 時(shí)間操作基類(支持短日期,長(zhǎng)日期,時(shí)間差)
- asp.net(C#)實(shí)現(xiàn)功能強(qiáng)大的時(shí)間日期處理類完整實(shí)例
- asp.net基于Calendar實(shí)現(xiàn)blog日歷功能示例
相關(guān)文章
asp.net中上傳圖片文件實(shí)現(xiàn)防偽圖片水印并寫入數(shù)據(jù)庫
asp.net上傳圖片文件實(shí)現(xiàn)防偽圖片水印并寫入數(shù)據(jù)庫,需要的朋友可以參考下。2010-10-10asp.net access web.config denied
如果出現(xiàn)這個(gè)問題,最好首先檢查一下ASPNET的帳號(hào),是否有訪問權(quán)限。2009-04-04.NET性能優(yōu)化之為集合類型設(shè)置初始大小的方法
這篇文章主要介紹了.NET性能優(yōu)化之為集合類型設(shè)置初始大小的方法,今天要談的一個(gè)性能優(yōu)化的Tips是一個(gè)老生常談的點(diǎn),但是也是很多人沒有注意的一個(gè)點(diǎn)。在使用集合類型是,你應(yīng)該設(shè)置一個(gè)預(yù)估的初始大小,那么為什么需要這樣做?我們一起來從源碼的角度說一說2022-05-05在ASP.NET Core中用HttpClient發(fā)送POST, PUT和DELETE請(qǐng)求
這篇文章主要介紹了在ASP.NET Core中用HttpClient發(fā)送POST, PUT和DELETE請(qǐng)求的方法,幫助大家更好的理解和學(xué)習(xí)使用ASP.NET Core,感興趣的朋友可以了解下2021-03-03asp.net core服務(wù)限制堆內(nèi)存大小的操作方法
asp.net core是微軟旗下支持跨平臺(tái)的開發(fā)框架,與springboot思想類似,支持ioc等,可以快速的開發(fā)web api等項(xiàng)目,這篇文章主要介紹了asp.net core服務(wù)限制堆內(nèi)存大小,需要的朋友可以參考下2022-09-09.NET實(shí)現(xiàn)微信公共平臺(tái)上傳下載多媒體文件
這篇文章主要介紹了.NET實(shí)現(xiàn)微信公共平臺(tái)上傳下載多媒體文件的相關(guān)資料,感興趣的小伙伴們可以參考一下2016-07-07微信公眾平臺(tái)開發(fā)教程(八)Session處理問題
本篇文章主要介紹了微信公眾平臺(tái)開發(fā)教程(八)Session處理 ,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。2016-12-12