单击ASP.NET日历控件单元格选择日期
2010-12-29 12:56
609 查看
单击ASP.NET日历控件老是选择数字才能选择这个日期,当数字很小的时候选择很不方便,以下方式可以单击单元格来选择日期:
Default.aspx代码:
Default.aspx.cs代码:
运行结果:
Default.aspx代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebAppCalendar._Default" %> <!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 runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Calendar ID="Calendar1" runat="server" Height="212px" ondayrender="Calendar1_DayRender" Width="390px"></asp:Calendar> </div> </form> </body> </html>
Default.aspx.cs代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebAppCalendar { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { //为日历单元格添加onClick事件 e.Cell.Attributes.Add("onClick", e.SelectUrl); //鼠标变为手型 e.Cell.Attributes.Add("onmouseover", "if(true) this.style.cursor='hand';"); } } }
运行结果:
相关文章推荐
- 改造asp.net日历控件为弹出式日期选择控件和GridView呈现长文本字段的两个技巧
- 改造asp.net日历控件为弹出式日期选择控件和GridView呈现长文本字段的两个技巧
- 2015-11-04 asp.net 弹出式日历控件 选择日期 Calendar控件
- asp.net 弹出式日历控件 选择日期 Calendar控件
- asp.net 弹出式日历控件 选择日期 Calendar控件
- 选择日期Excel日历控件将日期插入到指定单元格实例
- ASP.NET(c#) 日期选择控件的另一种实现方法
- asp.net中的时间日期选择控件
- ASP.NET弹出式日历选择控件的实现
- 发布 ASP.NET 日期选择控件 For VS2005 V2.0 SP1
- ASP.NET日期选择控件
- asp.net日期选择控件TestControl(v1.0.1).rar
- ASP.NET弹出式日历选择控件的实现
- 如何在Excel里单击一个单元格弹出一个日期选择控件,选择日期值后返回给该单元格。
- ASP.NET基础教程-Calendar日期选择控件的使用
- ASP.NET日历控件短日期及长日期的查询
- asp.net中的时间日期选择控件
- ASP.NET Calendar日历(日期)控件使用方法
- asp.net中的时间日期选择控件
- (转)ASP.NET弹出式日历选择控件的实现-可用于模块对话框