在ASP.NET中实现弹出日历的具体方法
2013-07-23 00:00
806 查看
ctlCalendar.ascx的源代码:
ctlCalendar.ascx.cs的源代码:
<%@ 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 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器 /// 修改此方法的内容。 /// </summary> private void InitializeComponent() { this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged); this.Load += new System.EventHandler(this.Page_Load); } #endregion #region 日历选择时的事件 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中实现弹出日历的具体方法
- asp.net类似于QQ表情弹出框功能的实现方法
- asp.net静态方法弹出对话框实现思路
- ASP.NET中URL Rewrite的具体实现方法
- Asp.net实现弹出窗口提示,又防止刷新被重复提交的方法
- Asp.net中把Excel数据存储至SQL Server中的具体实现方法
- ASP.NET中的几种弹出框提示基本实现方法
- 【翻译】在ASP.NET中实现弹出日历
- ASP.NET中的几种弹出框提示基本实现方法
- 【C#】对异步请求处理程序IHttpAsyncHandler的理解和分享一个易用性封装 【手记】走近科学之为什么明明实现了IEnumerable<T>的类型却不能调用LINQ扩展方法 【手记】手机网页弹出层后屏蔽底层的滑动响应 【手记】ASP.NET提示“未能创建类型”处理 【Web】一个非常简单的移动web消息框 【手记】解决EXCEL跑SQL遇“查询无法运行或数据库表无法打开...”
- 【补充】在ASP.NET中实现弹出日历
- ASP.Net后台 实现先弹出对话框,再跳转到另一个网页的实现方法
- ASP.NET中URL Rewrite的具体实现方法
- 在ASP.NET中实现弹出日历
- ASP.NET弹出对话框多种实现方法
- ASP.NET中的几种弹出框提示基本实现方法
- ASP.NET中实现弹出日历示例
- asp.net中使用DatagridView的增删改方法具体实现
- asp.net静态方法弹出对话框实现思路
- ASP.NET中的几种弹出框提示基本实现方法