国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

ASP.NET中實(shí)現(xiàn)彈出日歷示例

2024-07-10 12:49:38
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

在.net中彈出日歷的方法有很多種,這里介紹直接使用.net來(lái)實(shí)例,我們當(dāng)然還可以使用js日歷來(lái)實(shí)例哦,下面我分別簡(jiǎn)單舉兩個(gè)實(shí)例吧。有需要的朋友可以了解一下。

代碼如下:

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

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 的摘要說(shuō)明。 /// </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) {  // 在此處放置用戶代碼以初始化頁(yè)面  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ā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 宜兰市| 磐安县| 谷城县| 涟源市| 扶风县| 雅江县| 桐乡市| 循化| 中宁县| 金湖县| 许昌县| 六枝特区| 衡水市| 西青区| 连山| 临潭县| 南溪县| 深州市| 潞西市| 永泰县| 宕昌县| 平阳县| 禄丰县| 泾源县| 鄂托克前旗| 平度市| 绵阳市| 安义县| 汕头市| 台山市| 武夷山市| 达拉特旗| 宜丰县| 循化| 深州市| 太和县| 漳平市| 石门县| 铜川市| 墨脱县| 贺州市|