【控件代码怎么写】控件代码共享--日期选择控件

时间:2014-03-29  来源:php常用代码  阅读:
 
思路:实现日期年月日的选择
1、可以设定年的起止年份
2、排除不正确日期选择的可能
3、使用javascript实现控制
4、使用Text属性方便获取设置日期值
=================================
代码如下:
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Text;
using System.Web.UI;
using System.Web.UI.Design.WebControls;
using System.Web.UI.WebControls;
namespace JSY
{
///
/// AspNetDate 选择输入日期控件
///

[DefaultProperty("Text"),
ParseChildren(false),
PersistChildren(false),
Description("专用于ASP.Net Web应用程序的日期控件"),
Designer(typeof(DateDesigner)),
ToolboxData("<{0}:JSYNetDate runat=server>")]
public class JSYNetDate:Panel,INamingContainer,IPostBackDataHandler
{
#region 属性
///
/// 获取/设置日期值。
///

[Bindable(true),
Browsable(true),
Description("日期值"),
Category("外观"),
DefaultValue("")]
public string Text
{
get
{
if (ViewState["Text"] != null)
{
return ViewState["Text"].ToString();
}
else
{
if (IsNull)
{
return "";
}
else
{
DateTime date=System.DateTime.Today;
string str="";
switch (DateFormat)
{
case "YMD":
str=date.ToString("yyyy-MM-dd",System.Globalization.DateTimeFormatInfo.InvariantInfo);

【控件代码怎么写】控件代码共享--日期选择控件

http://m.bbyears.com/jiaocheng/5220.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新