Eric的日期选择下拉列表小控件

本文介绍了一种使用JS实现的日期选择功能,特别关注了闰年2月的日数变更处理,提供了一个简单实用的解决方案。通过DateDropDownList控件演示了如何在网页上创建日期选择器,并展示了如何设置默认日期及获取用户选择的日期。
利用JS实现日期选择功能,包括润年2月的日数变更, 简单实用! 主要属性: Date1012680.aspx

演示地址: http://efplatform.net/demo/webcontrols/datedropdownlist.aspx
下载地下: http://www.cnblogs.com/Files/ericfine/EFPlatform.WebControls.rar

DateDropDownList.aspx:
<% @ Page Language = " C# "   %>

<% @ Register Assembly = " EFPlatform.WebControls "  Namespace = " EFPlatform.WebControls "  TagPrefix = " efp "   %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

< script  runat ="server" >
    protected 
void  Page_Load(object sender, EventArgs e)
    {
        
this .DateDropDownList2.Date  =  DateTime.Today;
        
this .DateDropDownList3.Date  =  DateTime.Today.AddYears( - 20 );
        
this .DateDropDownList4.Date  =  DateTime.Parse( " 1981-12-16 " );
    }

    protected 
void  Button1_Click(object sender, EventArgs e)
    {
        
this .Label1.Text  =   this .DateDropDownList1.Date.ToShortDateString();
        
this .Label2.Text  =   this .DateDropDownList2.Date.ToShortDateString();
        
this .Label3.Text  =   this .DateDropDownList3.Date.ToShortDateString();
        
this .Label4.Text  =   this .DateDropDownList4.Date.ToShortDateString();
    }
</ script >

< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head  runat ="server" >
    
< title > DateDropDownList Demo </ title >
</ head >
< body >
    
< form  id ="form1"  runat ="server" >
        
< div >
            
< efp:DateDropDownList  ID ="DateDropDownList1"  runat ="server"   />
            
< br  />
            
< efp:DateDropDownList  ID ="DateDropDownList2"  runat ="server"   />
            
< br  />
            
< efp:DateDropDownList  ID ="DateDropDownList3"  runat ="server"   />
            
< br  />
            
< efp:DateDropDownList  ID ="DateDropDownList4"  runat ="server"   />
            
< asp:Button  ID ="Button1"  runat ="server"  OnClick ="Button1_Click"  Text ="Button"   />
            
< br  />
            
< br  />
            
< asp:Label  ID ="Label1"  runat ="server"  EnableViewState ="False" ></ asp:Label >
            
< br  />
            
< asp:Label  ID ="Label2"  runat ="server"  EnableViewState ="False" ></ asp:Label >
            
< br  />
            
< asp:Label  ID ="Label3"  runat ="server"  EnableViewState ="False" ></ asp:Label >
            
< br  />
            
< asp:Label  ID ="Label4"  runat ="server"  EnableViewState ="False" ></ asp:Label ></ div >
    
</ form >
</ body >
</ html >

转载于:https://www.cnblogs.com/ericfine/archive/2007/06/30/801565.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值