JavaScript做的ASP.NET的日期控件,很好用,推荐!

asp.net 时间日期控件 非常实用 asp.net中非常实用的一款时间日期控件,里面包含实用方法…… 立即下载

引用方法,如下:

<script language="javascript" type="text/javascript" src="Date.js"></script>
<input type="text" id="Date1" runat="server" readonly="readonly" /><input type="button" value="选择" onclick="popUpCalendar(Date1,'true');"/>

 

下面是Data.js的代码,将其拷到JS文件中,保存一下,注意文件格式要保存成UNICODE格式的。

 

var

showTime;

//是否必须点‘确定’按钮选择日期,true为必须,false直接选中,默认为false

var

needClickBtnOK = false;

//控件的暗色,默认为"#AAAAAA"

var

DarkColor;

//控件的亮色,默认为"#EEEEEE"

var

LightColor;

//控件的按钮背景色,默认为"#E6E6F6"

var

BtnBgColor;

//控件的文字颜色,默认为"#000080"

var

WordColor;

//控件的暗文字颜色,默认为"#AAAAAA"

var

WordDark;

//日期数字背景色,默认为"#DDDDDD"

var

DayBgColor;

//今天在日历上的标示背景色,默认为"#DD8333"

var

TodayColor;

//日期显示的立体表达色,默认为"#777777"

var

DarkBorder;

/**********************************************************

**********************************************************/

var

value;

var

strIframe;

var

popDiv;

var

popUp;

var

ifmElement;

var

ifm;

var

inputText;

var

nowTimeTemp;

var

WebCalendarWidth;

var

WebCalendarNowSelect;

var

WebCalendarDaysMonth;

var

WebCalendarDay;

var

WebCalendarDayObj;

var

WebCalendarDateStyle;

var

WebCalendarObjExport;

var

WebCalendarInputDate;

var

WebCalendarThisYear;

var

WebCalendarThisMonth;

var

WebCalendarThisDay;

var

WebCalendarToday;

var

WebCalendarDateReg;

var

WebCalendarYearFall;

var

WebCalendarFormat;

var

WebCalendarTimeShow;

var

WebCalendarDarkColor;

var

WebCalendarLightColor;

var

WebCalendarBtnBgColor;

var

WebCalendarWordColor;

var

WebCalendarWordDark;

var

WebCalendarDayBgColor;

var

WebCalendarTodayColor;

var

WebCalendarDarkBorder;

 

//弹出日历选择窗口,ctr为要设置日期的文本输入框id;

//showtime为是否显示时间,'true'为显示,'false'只显示日期

function

popUpCalendar(ctr,showtime){

try

{

if (showtime != 'true' && showtime != 'false')

{

alert(

"参数showtime必须为'true'或'false'");

return -1;

}

showTime=showtime;

popUp=

null;

initIt(ctr);

}

catch(exp){

}

}

function

initIt(ctr){

inputText = ctr;

value = inputText.value;

initVar();

showCalendar();

}

function

initVar(){

WebCalendarDaysMonth =

new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

WebCalendarDay =

new Array(42); //定义日历展示用的数组

WebCalendarDayObj =

new Array(42); //定义日期展示控件数组

WebCalendarDateStyle =

null; //保存格式化后日期数组

WebCalendarObjExport =

null; //日历回传的显示控件

WebCalendarInputDate =

null; //转化外的输入的日期(d/m/yyyy)

WebCalendarThisYear =

new Date().getFullYear(); //定义年的变量的初始值

WebCalendarThisMonth =

new Date().getMonth()+ 1; //定义月的变量的初始值

WebCalendarThisDay =

new Date().getDate(); //定义日的变量的初始值

//今天(d/m/yyyy)

WebCalendarToday = WebCalendarThisDay +

"/"+ WebCalendarThisMonth + "/" + WebCalendarThisYear;

WebCalendarNowSelect = WebCalendarToday;

WebCalendarDateReg =

""; //日历格式验证的正则式

WebCalendarYearFall = 50;

//定义年下拉框的年差值

WebCalendarFormat =

"yyyy-mm-dd"; //回传日期的格式

//是否返回时间

WebCalendarTimeShow = (showTime !=

null && showTime != 'false');

if (WebCalendarTimeShow){

WebCalendarWidth = 255;

}

else{

WebCalendarWidth = 242;

}

//控件的暗色

WebCalendarDarkColor = (DarkColor==

null) ? "#AAAAAA" : DarkColor;

//控件的亮色

WebCalendarLightColor = (LightColor==

null) ? "#EEEEEE" : LightColor;

//控件的按钮背景色

WebCalendarBtnBgColor = (BtnBgColor==

null) ? "#E6E6F6" : BtnBgColor;

//控件的文字颜色

WebCalendarWordColor = (WordColor==

null) ? "#000080" : WordColor;

//控件的暗文字颜色

WebCalendarWordDark = (WordDark==

null) ? "#AAAAAA" : WordDark;

//日期数字背景色

WebCalendarDayBgColor = (DayBgColor==

null) ? "#DDDDDD" : DayBgColor;

//今天在日历上的标示背景色

WebCalendarTodayColor = (TodayColor==

null) ? "#DD8333" : TodayColor;

//日期显示的立体表达色

WebCalendarDarkBorder = (DarkBorder==

null) ? "#777777" : DarkBorder;

nowTimeTemp =

new Date();

nowTimeTemp.setHours(0);

nowTimeTemp.setMinutes(0);

nowTimeTemp.setSeconds(0);

if (value != null && value.trim().length > 0){

var timeStr = value;

var spaceP = timeStr.indexOf(" ");

var timeStr = timeStr.substr(spaceP);

var timesArray = timeStr.split(":");

var hnn = timesArray[0];

var mnn = timesArray[1];

var snn = timesArray[2];

nowTimeTemp.setHours(hnn);

nowTimeTemp.setMinutes(mnn);

nowTimeTemp.setSeconds(snn);

}

}

function

showCalendar(){

if (popUp==null) {

popUp = window.createPopup();

var oPopBody = popUp.document.body;

writeIframe();

}

//edit 2005-11-23

if(WebCalendarTimeShow){

popUp.show(

event.screenX+10 , event.screenY+10 , WebCalendarWidth+2, 220);

}

else{

popUp.show(

event.screenX+10 , event.screenY+10 , WebCalendarWidth+2, 214);

}

//popUp.show( event.screenX+10 , event.screenY+10 , WebCalendarWidth+2, 214);

calendar();

}

function

Iframe(){

try{

var selYLeft = 58;

var selMleft=133;

/*if(WebCalendarTimeShow){

selYLeft=58;

selMleft=133;

}*/

strIframe =

"<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><style>" + "*{font-size: 12px; font-family: 宋体}" + ".bg{ color: " + WebCalendarLightColor + "; cursor: default; background-color: " + WebCalendarDarkColor + ";}" +

"table#tableMain{ width: "+WebCalendarWidth+"; height: 180;}" +

" table#tableWeek td{ text-align:center; color: " + WebCalendarLightColor + ";}" +

"table#tableDay td{ font-weight: bold;}" +

"td#kxYearHead, td#kxYearMonth{ text-align:center; color: " + WebCalendarWordColor + "}" +

".over { text-align: center; border-top: 1px solid " + WebCalendarLightColor + ";border-left: 1px solid " + WebCalendarLightColor + ";" + "border-right: 1px solid " + WebCalendarDarkBorder + "; border-bottom: 1px solid " + WebCalendarDarkBorder + ";}" +

".selected { text-align: center; border-top: 1px solid " + WebCalendarDarkBorder + ";border-left: 1px solid " + WebCalendarDarkBorder + ";" + "border-right: 1px solid " + WebCalendarLightColor + "; border-bottom: 1px solid " + WebCalendarLightColor + ";}" +

".out{ text-align: center; border-top: 1px solid " + WebCalendarLightColor + "; border-left: 1px solid " + WebCalendarLightColor + ";" + "border-bottom: 1px solid " + WebCalendarDarkBorder + "; border-right: 1px solid " + WebCalendarDarkBorder + "}" +

".inputstyle{ border: 1px solid " + WebCalendarDarkColor

+

"; padding-top: 1px; height: 20; cursor: hand;" + " color:" + WebCalendarWordColor + "; background-color: " + WebCalendarBtnBgColor + "}" +

"</style></head>";

strIframe+=

"<body onselectstart='return false;' scrolling='no' style='overflow:hidden;margin: 0px;border: 1px solid "+WebCalendarDarkBorder+";' oncontextmenu='return false;'><form id=kx>";

strIframe +=

"<select id='tmpYearSelect' style='z-index:1;position:absolute;top:3;left:"+selYLeft+";display:none'>"+

"</select>"+

"<select id='tmpMonthSelect' style='z-index:1; position:absolute;top:3;left:"+selMleft+";display:none'"+

"></select>"+

"<table id=tableMain class=bg border=0 cellspacing=0 cellpadding=1>"+

"<tr><td height=20 bgcolor='"+ WebCalendarLightColor +"'>"+

" <table width=100% id=tableHead border=0 cellspacing=1 cellpadding=0><tr align=center>"+

" <td width='50' align='left' height=20 class=bg ><input id=prevYear title='向前翻 1 年' class='inputstyle' type=button value='&lt;&lt; '"+

" onfocus='this.blur()' style='kx:expression(this.disabled=parent.WebCalendarThisYear==1000)'><input"+

" onfocus='this.blur()' id=prevMonth title='向前翻 1 月' class='inputstyle' type=button value=' &lt;&nbsp;'></td>"+

" <td width='120' id=kxYearHead title='点击此处选择年份'"+

" onmouseover=/"this.bgColor='"+WebCalendarDarkColor+"'; this.style.color='"+WebCalendarLightColor+"';/""+

" onmouseout=/"this.bgColor='"+WebCalendarLightColor+"'; this.style.color='"+WebCalendarWordColor+"';/"></td>"+

" <td width='120' id=kxYearMonth title='点击此处选择月份'"+

" onmouseover=/"this.bgColor='"+WebCalendarDarkColor+"'; this.style.color='"+WebCalendarLightColor+"'/""+

" onmouseout=/"this.bgColor='"+WebCalendarLightColor+"'; this.style.color='"+WebCalendarWordColor+"'/"></td>"+

" <td align='right' class=bg ><input title='向后翻 1 月' class='inputstyle' id=nextMonth type=button value='&nbsp;&gt; '"+

" onfocus='this.blur()'><input id=nextYear title='向后翻 1 年' class='inputstyle' type=button value='&gt;&gt; '"+

" onfocus='this.blur()' style='kx:expression(this.disabled=parent.WebCalendarThisYear==9999)'></td></tr></table>"+

"</td></tr><tr><td height=20px>";

strIframe +=

"<table id=tableWeek border=1 width=100% cellpadding=0 cellspacing=0";

strIframe +=

" borderColorLight='#888888' borderColorDark='#DDDDDD'>"+

" <tr align='center' height=20px><td background='#CCC000'>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr></table>"+

"</td></tr><tr><td valign='middle' height='122px'>"+

" <table bgcolor='"+WebCalendarDarkColor+"' id=tableDay height='100%' width='100%' cellspacing=0 cellpadding=0>";

//new Array ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")

for (var x = 0; x < 5; x++)

{

strIframe +=

"<tr height='20px'>";

for (var y = 0; y < 7; y++)

strIframe +=

"<td class=out id='kxDay" + (x * 7+y) + "'></td>";

strIframe +=

"</tr>";

}

strIframe +=

"<tr>";

for(var x=35; x<42; x++) {

strIframe +=

"<td class=out id='kxDay"+ x +"'></td>";

}

strIframe +=

"</tr></table>"+

" </td></tr><tr><td height=20 bgcolor='"+ WebCalendarLightColor +"'>"+

" <table border=0 cellpadding=1 cellspacing=0 width=100%>"+

" <tr height='18px'><td id='nowSelectObj' width='89px'>&nbsp;</td><td colspan=2 align='left'>";

if (WebCalendarTimeShow){

//var nowTimeTemp = new Date();

strIframe+=

"<INPUT type='text' readonly id='hou' style='LEFT: 84px; WIDTH: 20px; POSITION: absolute; TOP: 172px; HEIGHT: 16px'>";

strIframe+=

"<INPUT id='addhour' style='Z-INDEX: 101; LEFT: 105px; WIDTH: 16px; POSITION: absolute; TOP: 172px; HEIGHT: 8px' type='button' value=''>";

strIframe+=

"<INPUT id='subhour' style='Z-INDEX: 102; LEFT: 105px; WIDTH: 16px; POSITION: absolute; TOP: 181px; HEIGHT: 8px' type='button' value=''>";

strIframe+=

"<span style='LEFT: 122px; POSITION: absolute; '>时</span>";

strIframe+=

"<INPUT id='min' readonly style='LEFT: 137px; WIDTH: 20px; POSITION: absolute; TOP: 172px; HEIGHT: 16px' type='text'>";

strIframe+=

"<INPUT id='addmin' style='Z-INDEX: 103; LEFT: 158px; WIDTH: 16px; POSITION: absolute; TOP: 172px; HEIGHT: 8px' type='button' value='Button'>";

strIframe+=

"<INPUT id='submin' style='Z-INDEX: 104; LEFT: 158px; WIDTH: 16px; POSITION: absolute; TOP: 181px; HEIGHT: 8px' type='button' value='Button'>";

strIframe+=

"<span style='LEFT: 175px; POSITION: absolute; '>分</span>";

strIframe+=

"<INPUT id='sec' readonly style='LEFT: 190px; WIDTH: 20px; POSITION: absolute; TOP: 172px; HEIGHT: 16px' type='text'>";

strIframe+=

"<INPUT id='addsec' style='Z-INDEX: 105; LEFT: 211px; WIDTH: 16px; POSITION: absolute; TOP: 172px; HEIGHT: 8px' type='button' value='Button'>";

strIframe+=

"<INPUT id='subsec' style='Z-INDEX: 106; LEFT: 211px; WIDTH: 16px; POSITION: absolute; TOP: 181px; HEIGHT: 8px' type='button' value='Button'>";

strIframe+=

"<span style='LEFT: 228px; POSITION: absolute; '>秒</span>";

/*

*/

}

strIframe+=

"&nbsp;</td></tr>"+

" <tr><td align='left'>&nbsp</td><td align=center>"+

" </td><td align='right'><input name=today type=button value='现在' onfocus='this.blur()' class='inputstyle' style='width: 30' title='当前日期'>&nbsp;<input name='doOk' type=button value='确定' onfocus='this.blur()' class='inputstyle' style='width: 30'>&nbsp;<input type='button' name='closeCalendar' value='关闭' class='inputstyle' style='width: 30' title='取消'></td></tr></table>"+

"</td></tr><table></form></body></html>";

}

catch(excp4) {}

}

var

interset;

function

writeIframe(){

if (strIframe == null){

Iframe();

}

with(popUp)

{

document.writeln(strIframe);

document.close();

//document.body.onkeydown=doKeyDown;

with(document.all){

kxYearHead.onclick=funYearSelect;

kxYearMonth.onclick=funMonthSelect;

prevYear.onclick=prevY;

prevMonth.onclick=prevM;

nextMonth.onclick=nextM;

nextYear.onclick=nextY;

today.onclick=setToday;

tmpYearSelect.onchange=newYearSelect;

tmpYearSelect.onblur=hiddenSelect;

tmpMonthSelect.onchange=newMonthSelect;

tmpMonthSelect.onblur=hiddenSelect;

doOk.onclick=returnDate;

closeCalendar.onclick=hiddenCalendar;

for(var i=0; i<42; i++)

{

WebCalendarDayObj[i] = eval(

"kxDay"+ i);

WebCalendarDayObj[i].onmouseover = dayMouseOver;

WebCalendarDayObj[i].onmouseout = dayMouseOut;

WebCalendarDayObj[i].onmouseup = newDateSelect;

//WebCalendarDayObj[i].onclick = newDateSelect;

}

if (WebCalendarTimeShow){

//

//addhour.onclick=addH;

addhour.onmousedown=addHour;

addhour.onmouseup=addaHou;

addhour.onmouseout=stop;

//

//subhour.onclick=subH;

subhour.onmousedown=subHour;

subhour.onmouseup=subaHou;

subhour.onmouseout=stop;

//

//addmin.onclick=addM;

addmin.onmousedown=addMin;

addmin.onmouseup=addaMin;

addmin.onmouseout=stop;

//

//submin.onclick=subM;

submin.onmousedown=subMin;

submin.onmouseup=subaMin;

submin.onmouseout=stop;

//

//addsec.onclick=addS;

addsec.onmousedown=addSec;

addsec.onmouseup=addaSec;

addsec.onmouseout=stop;

//

//subsec.onclick=subS;

subsec.onmousedown=subSec;

subsec.onmouseup=subaSec;

subsec.onmouseout=stop;

//

popUp.document.all.hou.value = appendZero(nowTimeTemp.getHours());

popUp.document.all.min.value = appendZero(nowTimeTemp.getMinutes());

popUp.document.all.sec.value = appendZero(nowTimeTemp.getSeconds());

}

}

}

}

//

function

stop(){

clearInterval(interset);

}

function

addHour(){

clearInterval(interset);

interset=setInterval(

"addH()",120);

}

function

addaHou(){

stop();

addH();

}

function

subaHou(){

stop();

subH();

}

function

subHour(){

clearInterval(interset);

interset=setInterval(

"subH()",120);

}

function

addH(){

var h = parseInt(popUp.document.all.hou.value,10) + 1;

popUp.document.all.hou.value = h > 23?

"00" : (h<10?appendZero(h):h);

}

function

subH(){

var h = parseInt(popUp.document.all.hou.value,10) - 1;

popUp.document.all.hou.value=h < 0 ?

"23" : appendZero(h);

}

function

addaMin(){

stop();

addM();

}

function

subaMin(){

stop();

subM();

}

function

addMin(){

clearInterval(interset);

interset=setInterval(

"addM()",120);

}

function

subMin(){

clearInterval(interset);

interset=setInterval(

"subM()",120);

}

function

addM(){

var m = parseInt(popUp.document.all.min.value,10) + 1;

popUp.document.all.min.value = m > 59?

"00" : appendZero(m);

}

function

subM(){

var m = parseInt(popUp.document.all.min.value,10) - 1;

popUp.document.all.min.value = m < 0?

"59" : appendZero(m);

}

function

addaSec(){

stop();

addS();

}

function

subaSec(){

stop();

subS();

}

function

addSec(){

clearInterval(interset);

interset=setInterval(

"addS()",120);

}

function

subSec(){

clearInterval(interset);

interset=setInterval(

"subS()",120);

}

function

addS(){

var s = parseInt(popUp.document.all.sec.value,10) + 1;

popUp.document.all.sec.value = s > 59?

"00" : appendZero(s);

}

function

subS(){

var s = parseInt(popUp.document.all.sec.value,10) - 1;

popUp.document.all.sec.value = s < 0?

"59" : appendZero(s);

}

//

function

appendZero(n){

return (("00" + n).substr(("00" + n).length - 2));

}

function

String.prototype.trim(){

return this.replace(/(^/s*)|(/s*$)/g,"");

}

function

hiddenSelect(nows){

try{

var ee=nows;

for(var i = (ee.options.length - 1); i > -1; i--)

{

ee.options.remove(i);

}

nows.style.display=

"none";

}

catch(e){}

}

function

hiddenCalendar(){

if(popUp){

if(popUp.isOpen){

popUp.hide();

}

}

}

function

dayMouseOver(){

try{

this.style.backgroundColor = WebCalendarWordDark;

var d = WebCalendarDay[this.id.substr(5)];

if (WebCalendarNowSelect == d) {

return ;

}

this.className = "over";

if (d.split("/")[1] == WebCalendarThisMonth) {

this.style.color = WebCalendarLightColor;

}

else{

this.style.color = WebCalendarLightColor;

}

}

catch(excp5) {}

}

function

dayMouseOut() {

try{

var d = WebCalendarDay[this.id.substr(5)];

if (WebCalendarNowSelect == d) {

if(WebCalendarNowSelect == WebCalendarToday){

this.style.background = WebCalendarTodayColor;

}

return ;

}

if (WebCalendarInputDate==d){

this.bgColor = WebCalendarWordDark;

this.style.color = WebCalendarLightColor;

}

this.className = "out";

a = d.split(

"/");

this.style.removeAttribute('backgroundColor');

if (a[1] == WebCalendarThisMonth && d != WebCalendarToday) {

if (WebCalendarDateStyle && a[0] == parseInt(WebCalendarDateStyle[4], 10)) {

this.style.background = WebCalendarLightColor;

}

this.style.color = WebCalendarWordColor;

}

else if (d == WebCalendarToday){

this.style.color = WebCalendarLightColor;

}

else{

this.style.color = WebCalendarWordDark;

}

}

catch(excp6) {}

}

 

function

newYearSelect(){

WebCalendarThisYear =

this.value;

writeCalendar();

hiddenSelect(popUp.document.all.tmpYearSelect);

}

function

hidenYearSelect(){

hiddenSelect(popUp.document.all.tmpYearSelect);

}

function

newMonthSelect(){

WebCalendarThisMonth=

this.value;

hiddenSelect(popUp.document.all.tmpMonthSelect);

writeCalendar();

}

function

hidenMonthSelect(){

hiddenSelect(popUp.document.all.tmpMonthSelect);

}

function

hiddenAllSelect(){

hidenMonthSelect();

hidenYearSelect();

}

function

setToday(){

WebCalendarNowSelect = WebCalendarToday;

var a = WebCalendarToday.split("/");

WebCalendarThisYear = a[2];

WebCalendarThisMonth = a[1];

WebCalendarThisDay = a[0];

if(WebCalendarTimeShow){

nowTimeTemp =

new Date();

writeIframe();

}

writeCalendar();

}

function

calendar(){

var e = window.event.srcElement;

WebCalendarObjExport = inputText;

if (!WebCalendarTimeShow) WebCalendarDateReg = /^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})$/;

else WebCalendarDateReg = /^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2}) (/d{1,2}):(/d{1,2}):(/d{1,2})$/;

try

{

if (WebCalendarObjExport.value.trim() != ""){

WebCalendarDateStyle = WebCalendarObjExport.value.trim().match(WebCalendarDateReg);

if (WebCalendarDateStyle == null)

{

WebCalendarThisYear =

new Date().getFullYear();

WebCalendarThisMonth =

new Date().getMonth()+ 1;

WebCalendarThisDay =

new Date().getDate();

alert(

"原文本框里的日期有错误!/n可能与你定义的显示时分秒有冲突!");

writeCalendar();

return false;

}

else

{

WebCalendarThisYear = parseInt(WebCalendarDateStyle[1], 10);

WebCalendarThisMonth = parseInt(WebCalendarDateStyle[3], 10);

WebCalendarThisDay = parseInt(WebCalendarDateStyle[4], 10);

WebCalendarInputDate = parseInt(WebCalendarThisDay, 10) +

"/" +

parseInt(WebCalendarThisMonth, 10) +

"/" +

parseInt(WebCalendarThisYear, 10);

WebCalendarNowSelect = WebCalendarInputDate;

writeCalendar();

return;

}

}

else writeCalendar();

}

catch(e){writeCalendar();}

}

function

funMonthSelect(){

hidenYearSelect();

popUp.document.all.kxYearMonth.innerText=

"";

var y = WebCalendarThisYear;

popUp.document.all.kxYearHead.innerText = y +

" 年";

var m = isNaN(parseInt(WebCalendarThisMonth, 10)) ? (new Date().getMonth() + 1) : parseInt(WebCalendarThisMonth, 10);

var ee = popUp.document.all.tmpMonthSelect;

var tempStrOption = "";

for(var i = 1; i < 13; i++)

{

var op =popUp.document.createElement("OPTION");

op.value = i;

//op.text = i + "月";

op.text = i +

"月";

ee.add(op);

}

ee.style.display =

"inline";

ee.value = m;

try{

ee.focus();

}

catch(ex){}

}

function

funYearSelect(){

hidenMonthSelect();

popUp.document.all.kxYearHead.innerText=

"";

var m = WebCalendarThisMonth;

popUp.document.all.kxYearMonth.innerText = parseInt(m, 10) +

" 月";

var es = popUp.document.forms[0].tmpYearSelect;

var n = WebCalendarYearFall;

var y = isNaN(parseInt(WebCalendarThisYear, 10)) ? (new Date().getFullYear()) : parseInt(WebCalendarThisYear);

y = (y <= 1000) ? 1000 : ((y >= 9999) ? 9999 : y);

var min = (y - n >= 1000) ? y - n: 1000;

var max = (y + n <= 9999) ? y + n: 9999;

min = (max == 9999) ? max - n * 2: min;

max = (min == 1000) ? min + n * 2: max;

for (var i = min; i <= max; i++)

{

var op = popUp.document.createElement("OPTION");

op.value = i;

//op.text = i + "年";

op.text = i +

"年";

es.add(op);

}

es.style.display =

"";

es.value = y;

try{

es.focus();

}

catch(e) {}

}

//往前翻月份

function

prevM()

{

try{

//WebCalendarThisDay = 1;

hidenYearSelect();

hidenMonthSelect();

if (WebCalendarThisMonth==1)

{

WebCalendarThisYear--;

WebCalendarThisMonth=13;

}

WebCalendarThisMonth--;

writeCalendar();

}

catch(e) {}

}

//往后翻月份

function

nextM()

{

try{

//WebCalendarThisDay = 1;

hidenYearSelect();

hidenMonthSelect();

if (WebCalendarThisMonth==12)

{

WebCalendarThisYear++;

WebCalendarThisMonth=0;

}

WebCalendarThisMonth++;

writeCalendar();

}

catch(e) {}

}

//往前翻 Year

function

prevY()

{

try

{

//WebCalendarThisDay = 1;

hidenYearSelect();

hidenMonthSelect();

WebCalendarThisYear--;

writeCalendar();

}

catch(e) {}

}

//往后翻 Year

function

nextY()

{

try

{

//WebCalendarThisDay = 1;

hidenYearSelect();

hidenMonthSelect();

WebCalendarThisYear++;

writeCalendar();

}

catch(e) {}

}

function

writeCalendar()

{

try

{

var y = WebCalendarThisYear;

var m = WebCalendarThisMonth;

var d = WebCalendarThisDay;

WebCalendarDaysMonth[1] = (0==y%4 && (y%100!=0 || y%400==0)) ? 29 : 28;

if (!(y <= 9999 && y >= 1000 && parseInt(m, 10) > 0 && parseInt(m, 10) < 13 && parseInt(d, 10) > 0)){

alert(

"对不起,你输入了错误的日期!");

WebCalendarThisYear =

new Date().getFullYear();

WebCalendarThisMonth =

new Date().getMonth() + 1;

WebCalendarThisDay =

new Date().getDate();

}

y = WebCalendarThisYear;

m = WebCalendarThisMonth;

d = WebCalendarThisDay;

popUp.document.all.kxYearHead.innerText = y +

" 年";

popUp.document.all.kxYearMonth.innerText = parseInt(m, 10) +

" 月";

//闰年二月为29天

WebCalendarDaysMonth[1] = (0==y%4 && (y%100!=0 || y%400==0)) ? 29 : 28;

var w = new Date(y, m-1, 1).getDay();

var prevDays = (m==1) ? WebCalendarDaysMonth[11] : WebCalendarDaysMonth[m-2];

//这三个 for 循环为日历赋数据源(数组 WebCalendarDay)格式是 d/m/yyyy

for(var i=(w-1); i>=0; i--)

{

WebCalendarDay[i] = prevDays +

"/" + (parseInt(m, 10)-1) + "/" + y;

if(m==1) WebCalendarDay[i] = prevDays +"/"+ 12 +"/"+ (parseInt(y, 10)-1);

prevDays--;

}

for(var i=1; i<=WebCalendarDaysMonth[m-1]; i++) WebCalendarDay[i+w-1] = i + "/" + m + "/" + y;

for(var i=1; i<42-w-WebCalendarDaysMonth[m-1]+1; i++)

{

WebCalendarDay[WebCalendarDaysMonth[m-1]+w-1+i] = i +

"/" + (parseInt(m, 10)+1) + "/" + y;

if(m==12) WebCalendarDay[WebCalendarDaysMonth[m-1]+w-1+i] = i +"/"+ 1 +"/"+ (parseInt(y, 10)+1);

}

//edit 2005-11-29 15:42

if (WebCalendarDaysMonth[m-1]<d)

{

d=WebCalendarDaysMonth[m-1];

WebCalendarThisDay=d;

}

WebCalendarNowSelect=d +

"/" + m + "/" + y;

//显示当前选择的时间

var tempArray=WebCalendarNowSelect.split("/");

popUp.document.all.nowSelectObj.innerHTML=tempArray[2]+

"-"+appendZero(tempArray[1])+"-"+appendZero(tempArray[0])+"";

//这个循环是根据源数组写到日历里显示

for(var i=0; i<42; i++){

var a = WebCalendarDay[i].split("/");

WebCalendarDayObj[i].className=

'out';

WebCalendarDayObj[i].innerText = a[0];

WebCalendarDayObj[i].title = a[2] +

"-"+ appendZero(a[1]) +"-"+ appendZero(a[0]);

WebCalendarDayObj[i].bgColor = WebCalendarDayBgColor;

WebCalendarDayObj[i].style.color = WebCalendarWordColor;

WebCalendarDayObj[i].style.removeAttribute(

'backgroundColor');

if ((i<10 && parseInt(WebCalendarDay[i], 10)>22) || (i>27 && parseInt(WebCalendarDay[i], 10)<14)){

WebCalendarDayObj[i].style.color = WebCalendarWordDark;

}

//设置输入框里的日期在日历上的颜色

if (WebCalendarInputDate==WebCalendarDay[i]){

WebCalendarDayObj[i].bgColor = WebCalendarDarkColor;

WebCalendarDayObj[i].style.color = WebCalendarLightColor;

}

//设置今天在日历上反应出来的颜色

if (WebCalendarDay[i] == WebCalendarToday)

{

WebCalendarDayObj[i].bgColor = WebCalendarTodayColor; WebCalendarDayObj[i].style.color = WebCalendarLightColor;

}

if(WebCalendarDay[i] == WebCalendarNowSelect){

WebCalendarDayObj[i].className=

'selected';

WebCalendarDayObj[i].style.color=WebCalendarLightColor;

if(WebCalendarToday!=WebCalendarNowSelect){

WebCalendarDayObj[i].style.background = WebCalendarDarkColor;

}

}

}

if(WebCalendarTimeShow){

popUp.document.all.hou.value = appendZero(nowTimeTemp.getHours());

popUp.document.all.min.value = appendZero(nowTimeTemp.getMinutes());

popUp.document.all.sec.value = appendZero(nowTimeTemp.getSeconds());

}

}

catch(excp2){

}

}

//根据日期格式等返回用户选定的日期

function

newDateSelect()

{

if (needClickBtnOK)

{

if(WebCalendarObjExport)

{

var selectObj = (arguments.length==0) ? WebCalendarDay[this.id.substr(5)]: arguments[0];

var a = selectObj.split("/");

WebCalendarNowSelect = WebCalendarDay[

this.id.substr(5)];

if(a[2]>WebCalendarThisYear){

nextM();

}

else if(a[2]<WebCalendarThisYear){

prevM();

}

else if(a[1]>WebCalendarThisMonth){

nextM();

}

else if(a[1]<WebCalendarThisMonth){

prevM();

}

else{

writeCalendar();

}

}

}

else

{

if(WebCalendarObjExport)

{

WebCalendarNowSelect = WebCalendarDay[

this.id.substr(5)];

returnDate();

}

}

}

function

returnDate() {

if (WebCalendarObjExport) {

var returnValue;

var a = (arguments.length == 0) ? WebCalendarNowSelect.split("/"): arguments[0].split("/");

var d = WebCalendarFormat.match(/^(/w{4})(-|//)(/w{1,2})/2(/w{1,2})$/);

if (d == null) {

alert(

"你设定的日期输出格式不对!/r/n/r/n请重新定义 WebCalendarFormat !");

return false;

}

//判断返回的日期格式是否要补零

var flag = d[3].length == 2 || d[4].length == 2;

returnValue = flag ? a[2] + d[2] + appendZero(a[1]) + d[2] + appendZero(a[0]) : a[2] + d[2] + a[1] + d[2] + a[0];

if (WebCalendarTimeShow) {

var h = popUp.document.all.hou.value;

var m = popUp.document.all.min.value;

var s = popUp.document.all.sec.value;

nowTimeTemp.setHours(h);

nowTimeTemp.setMinutes(m);

nowTimeTemp.setSeconds(s);

returnValue += flag ?

" " + appendZero(h) + ":" + appendZero(m) + ":" + appendZero(s): " " + h + ":" + m + ":" + s;

}

//var tempValue = WebCalendarObjExport.value;

WebCalendarObjExport.value = returnValue;

hiddenCalendar();

/*if(tempValue != returnValue){

onchangeID.fire();

} */

}

}

asp.net 第三方日历控件 第三方日期控件下载 很方便在asp.net中使用的日期控件,使用时一定要按照readme文件里的说明做,所下载的文件一个也不要删除,否则会出现想不到的错误。 立即下载

相关推荐

ASP.NET时间控件

好用的ASP.NET控件,一看就会,快来下载吧

日历控件

1、引用 WebCalendar.js&nbsp;&nbsp;&nbsp; &lt;script src="WebCalendar.js" type="text/javascript"&gt;&lt;/script&gt;2、编写触发的脚本事件&nbsp;&nbsp;&nbsp; this.Txt_Date.Attributes["onclick"] = "S

newpeter 185

非常好用的asp.net日期时间控件

1. 简介 功能强大、使用方便的日期时间控件,目前的版本是:4.1 正式版 发布于2008-10-20 2. 注意事项 My97DatePicker目录是一个整体,不可破坏里面的目录结构,也不可对里面的文件改名,可以改目录名 My97DatePicker.htm是必须文件,不可删除 各目录及文件的用途: WdatePicker.js 配置文件,在调用的地方仅需使用该文件 config.js 语言和皮肤配置文件 calendar.js 日期库主文件) My97DatePicker.htm 临时页面文件,不可删除 目录lang 存放语言文件 目录skin 存放皮肤的相关文件 当WdatePicker.js里的属性:$wdate=true时,在input里加上class="Wdate"就会在选择框右边出现日期图标,如果您不喜欢这个样式,可以把class="Wdate"去掉,另外也可以通过修改skin目录下的WdatePicker.css文件来修改样式

asp.net中的时间日期选择控件

在系统中经常需要进行时间日期选择(比如查询时间范围内的信息、填写日期等),使用时间日期选择控件不仅能提高效率,而且不会写错格式! 现把自己在.net项目中经常使用的一款时间日期选择控件整理出来,希望对大家有所帮助! 首先大家来看看效果图: (gif格式,用于选择图标) js脚本: calendar.js vargd...

weixin_30709061的博客 787

Proteus 8.17安装部署全指南:避坑、汉化与STM32库配置

Proteus是一款广泛用于单片机仿真与电路设计的EDA工具,其核心价值在于支持嵌入式系统原型验证与教学实践。Proteus 8.17版本重构了许可证机制(LIC Engine)、依赖环境(VC++ 2019/NET 4.8)及路径加载逻辑,导致传统安装方法失效。掌握正确安装部署流程,是保障原理图绘制、VSM仿真(如51/STM32/ESP32)及外设波形观测(OLED、SPI、ADC)稳定运行的前提。本文聚焦Windows平台下零失败安装路径选择、权限配置、汉化实施与高频器件(如STM32F103)元件库

weixin_33377602的博客 402

等时替代模型( Isotemporal Substitution Model)

文献阅读:Associations of sedentary time and physical activity with adverse health conditions: Outcome-wide analyses using isotemporal substitution model(该论文于2022年4月28日发表在柳叶刀子刊 EClinicalMedicine 上)

姚巨龙的博客 1万+

asp.net 日历控件 js 开源 my97

1:先下载my97的文件包   坚持打造最好的日期控件,My97 DatePicker 4.7 Release[新增]输入智能调整,在输入日期时,会根据日期格式自动调整 [新增]默认显示快速选择的选项 [新增]周数算法选择 [新增]全键盘操作(键盘控制开关),不用鼠标也可以选择日期 [新增]dateFmt可以直接使用%y %M %d %ld等内置常量 [新增]isShowOK属性,可以隐藏确定按钮 [新增]当使用onfocus触发时,焦点在日期控件时,也会弹出日期控件 [新增]autoUpdateOnCha

wzsdoors的专栏 1100

转子动力学 | 临界速度与稳定性分析

本文深入探讨了转子动力学中的核心问题——临界速度与稳定性分析。临界速度是旋转机械发生共振的危险转速,通过模态分析和坎贝尔图可进行预测。文章还剖析了油膜涡动等稳定性问题,并结合ANSYS仿真案例,详细阐述了从建模、分析到设计优化的完整工程实践流程,为旋转机械的可靠设计与安全运行提供关键指导。

weixin_29313239的博客 518

ASP.NET 日期控件

控件使用方式下载地址:http://download.csdn.net/source/3518623  控件1.显示效果: 使用方法:将该Datepicker目录直接放到项目里面,界面上添加代码           $(function() {

做得最大的项目,就是人生 1万+

DSP配置I2C通讯(非IO口软件模拟时序)

dsp即数字信号处理器,是一种广泛应用的嵌入式处理器,主要应用是实时快速地实现各种数字信号处理算法,目前,国际主要的dsp供应商是ti公司,其tms32系列产品占据了dsp市场近一半的份额,本文以TMS320F28377D为例,使用ti公司dsp开发工具ccs10.1配置i2c模块。 写这篇文章的缘由,因为市面上很多DSP其实内部是具有硬件I2C接口的,但由于网络上大部分资料和例程都是利用IO口模拟I2C时序进而实现I2C通讯的。给很多想学习硬件I2C通讯的小伙伴带来了困难。 下面先介绍一下配置步骤 1.E

weixin_44387442的博客 5545

Netapp FAS2750热备盘替换失败问题分析与解决

本文深入分析了Netapp FAS2750存储系统中热备盘替换失败的故障现象,揭示了磁盘分区属主不匹配导致数据同步无法启动的根本原因。通过详细的排查步骤和解决方案,帮助运维人员快速恢复aggr状态,并提供了长期预防措施和最佳实践建议,确保存储系统的高可用性。

weixin_33737774的博客 399

MVC下使用日期控件

  初学MVC,使用日期控件的时候发现不是特别理想,本来是想直接使用JQuery的日期控件的,发现支持的不是很好,type类型要改成date才能使用,而且编辑的时候使用@Html.EditFor也不能绑定值,不知道大家有没有在项目中使用过Jquery的日期控件,有没有遇到什么问题,希望能控讨一下。   于是乎,在园友的推荐下,改用大名鼎鼎的My97,下载地址:http://www.my...

dichishang0477的博客 375

Dify 第 7 篇 Dify 应用介绍 + 聊天助手&Agent 应用关键点说明

本文介绍了Dify应用的核心概念与使用方法。Dify是基于大模型构建的实际场景应用,提供API、WebApp和易用界面。包含5种应用类型:聊天助手、文本生成、Agent、对话流和工作流。创建方式有模板创建、空白应用和DSL文件三种。重点讲解了聊天助手和Agent应用的关键功能:聊天助手支持提示词优化、知识库引用、文件处理等;Agent应用则强调推理能力、工具调用和任务自动化。文章还详细介绍了应用的调试、发布和管理工具,为开发者提供了全面的应用构建指南。

甘蓝的专栏 1884

JS日期控件

在进行开发的过程中,经常需要输入时间,特别是在进行查询、统计的时候,时间限定更为重要。       尽管ASP.NET也集成了日历控件,但是其集成的代码量很大,你可以做一个测试,当你在页面使用一个日历控件时,在发布之后查看该页面的源代码,你会惊奇发现,日历控件的代码量很庞大,这就大大增加的带宽的开销,每当一个客户端请求这个页面,服务器都要将如此庞大的代码进行发送,使得服务器负担加重。而且,A

刘鹏的技术宅 1277

【QNX+Android虚拟化方案】136 - QNX 侧 Coredump 文件解析

【QNX+Android虚拟化方案】136 - QNX 侧 Coredump 文件解析

|~~~热爱生活、努力学习的小伙汁~~~| 1909

Python 对接钉钉获取员工上一篇日报或周报内容

摘要:本文介绍使用Python对接钉钉API获取员工日报/周报的方法。首先需创建钉钉应用并开通日志权限,获取员工UserID。通过获取AccessToken进行鉴权,调用topapi/report/list查询日志记录,筛选最新日报/周报后,使用topapi/report/details获取详细内容。需注意权限控制、时间范围筛选和模板匹配等问题。文末提供完整代码示例,并建议扩展自动化触发、数据存储等功能。该方法适用于企业自动化获取员工工作日志的场景。

从技术实践立足,从项目管理方法论延伸思考 807

ASP.NET Core Telerik UI DatePicker精通指南:时区、绑定与实战

在Web开发中,表单处理是核心环节,而日期选择器作为表单的常见组件,其背后的数据绑定与状态管理原理至关重要。理解客户端与服务端的数据交互机制,尤其是日期时间值的序列化与反序列化过程,是确保数据一致性的基础。在ASP.NET Core框架下,通过模型绑定和验证技术,可以高效地将前端用户输入映射到后端强类型模型,这是提升开发效率和减少错误的关键。对于企业级应用,处理时区问题、实现动态日期禁用以及与模态框等复杂UI组件的集成,是日期选择器组件需要解决的核心技术挑战。这些实践不仅关乎功能实现,更直接影响用户体验和数

alince20008的博客 387

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

js 日期控件 多种样式

在进行开发的过程中,经常需要输入时间,特别是在进行查询、统计的时候,时间限定更为重要。 尽管ASP.NET也集成了日历控件,但是其集成的代码量很大,你可以做一个测试,当你在页面使用一个日历控件时,在发布之后查看该页面的源代码,你会惊奇发现,日历控件的代码量很庞大,这就大大增加的带宽的开销,每当一个客户端请求这个页面,服务器都要将如此庞大的代码进行发送,使得服务器负担加重。而且,A...

zshcomeon的专栏 669

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

日期控件

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34032779的博客 77

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

asp.net 日历控件

在进行开发的过程中,经常需要输入时间,特别是在进行查询、统计的时候,时间限定更为重要。 尽管ASP.NET也集成了日历控件,但是其集成的代码量很大,你可以做一个测试,当你在页面使用一个日历控件时,在发布之后查看该页面的源代码,你会惊奇发现,日历控件的代码量很庞大,这就大大增加的带宽的开销,每当一个客户端请求这个页面,服务器都要将如此庞大的代码进行发送,使得服务器负担加重。而且,AS...

weixin_30349597的博客 456

WaterCloud:一套基于.NET 8.0 + LayUI的快速开发框架,完全开源免费!

今天大姚给大家分享一套基于.NET 8.0 + LayUI的快速开发框架,项目完全开源、免费(MIT License)且开箱即用:WaterCloud。可完全实现二次开发让开发更多关注业务逻辑。既能快速提高开发效率,帮助公司节省人力成本,同时又不失灵活性。

专注于C#/.NET/.NET Core学习、工作、面试干货和实战教程分享。这里聚焦了大量的C#/.NET/.NET Core优质文章、开源项目、实用工具和学习、工作、面试心得。 2353

jquery插件总结与推荐

非IT企业或者个人一般都没有自己的库(偏前端),这个时候如果要开发网页,有的会选择类似EXTJS这样的商业库,这样可以减轻美工压力(对没有专业美工的企业来说甚至可以节省美工),并增加开发效率,但是我个人更喜欢jquery及其插件,下面就总结下我目前使用的一些插件:             下面这些基本上基于管理系统所必须拥有的功能而选择的插件           1.jquery 这个毋庸

bus2046 829

ASP.NET AJAX入门系列(2):使用ScriptManager控件

从这里开始,到(11)都是转载别人的,觉得写得不错.推荐给大家一起学习.ScriptManager控件包括在ASP.NET 2.0 AJAX Extensions中,它用来处理页面上的所有组件以及页面局部更新,生成相关的客户端代理脚本以便能够在JavaScript中访问Web Service,所有需要支持ASP.NET AJAX的ASP.NET页面上有且只能有一个ScriptManager控件

夏风鱼的专栏 469

大量JavaScript日历控件(some free Calendar control by JS)

RJS PopCalendar is really a good one, and there is a tutorial about it: Picking Dates with a Free RJS PopCalendar, a Free ASP.NET Popup Calendar Control http://aspnet.4guysfromrolla.com/articl...

weixin_30709929的博客 87
上一篇: 判断图像文件是否完好
下一篇: net中如何启动windows服务?
王子样
博客等级 码龄23年 19粉丝 46原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值