http://blog.csdn.net/hertcloud/archive/2007/04/12/1561713.aspx
这个日历可以
没必要用.net自己带那个控件
相当不好用
这个日历可以
没必要用.net自己带那个控件
相当不好用
解决方案 »
- 多表链接查询结果SqlDataAdapter Fill DataTable
- Response.Redirect("")能不能跳转到原来的页面?
- 浮动panel中的dropdownlist控件浏览器中呈现延迟
- Web service 连接的性能问题
- petshop4.0安装完后不能运行!!
- 怎么将DataTable数据按顺序画在Table里?
- 使用.net c#如何实现象QQ一样的即时提醒
- datagrid的删除问题
- 【求助】得不到Response.Write的值
- 关于在DataGrid中绑定DropDownList的问题:
- GridView问题
- asp.net中gridview中如何设两个主键
楼主可以找一个,做成ascx控件~
* My97日期控件 My97 DatePicker Ver 1.1
* 如果您在使用过程中遇到问题,或者有更好的建议
* 欢迎您访问
* BLOG: http://blog.csdn.net/my97/
* MAIL: [email protected]
*//* 全局字体定义,如果你已经定义过,可以删除 */
* {font-size:9pt;}/* 日期选择控件 */
.Wdate{
width:120px;
background:url(images/datePicker.gif) no-repeat right;
}
/* 日期选择容器 */
.WdateDiv{
position:absolute;
z-index:255;
width:180px;
background-color:#FFFFFF;
border:#bbb 1px solid;
padding:2px;
}
/* 控件内的input对象的通用设置 */
.WdateDiv input{
border: #cccccc 1px solid;
height:16px;
}
/* 年份月份栏 */
.WdateDiv #pickerTitle{
height:28px;
}
/* 星期栏 */
.WdateDiv #weekTitle{
background-color:#C0EBEF;
}
/* 年份月份输入框 右边 + - 按钮的CSS */
.WdateDiv button{
height:10px;
font-size:7;
width:13px;
border:#ccc 1px solid;
}
/* 年份月份输入框 */
.WdateDiv .yminput{
padding-top:2px;
text-align:center;
border:0px;
}
/* 年份月份输入框获得焦点时的样式 */
.WdateDiv .yminputfocus{
text-align:center;
font-weight:bold;
color:blue;
border-right:0px;
}
/* 日期格的样式 */
.WdateDiv .Wday{
}
/* 日期格的mouseover样式 */
.WdateDiv .WdayOn{
background-color:#C0EBEF;
}
function WdatePicker()
{
/* 设置 */
/* 星期标题 */
this.aWeekStr = ["日","一","二","三","四","五","六"];
/* css文件的路径 */
this.cssPath = "WdatePicker.js"; //最好用绝对路径 / 开头的
/* 输入错误日期时的提示信息 */
this.msgDateErr = "请输入一个正确的日期格式!";
/* 在没有看懂的情况下请不要修改以下代码 */
this.eCont = window.event.srcElement;
this.win = window;this.top = window;
while(this.top.parent.document != this.top.document && this.top.parent.document.getElementsByTagName("frameset").length == 0){this.top = this.top.parent;}
if(this.top.document.dateDiv){
$d = this.top.document.dateDiv;
if($d.errPos!=undefined && $d.errPos!=null){
if( !($d.obj.eCont.value == '' || $d.obj._isDate($d.obj.eCont.value)) ){$d.errPos.focus(); return; }else{$d.errPos = null;}
}
if($d.obj.eCont==this.eCont){$d.style.display = '';return;}
}
this._todayDate = new Date();
this.t_year = this._todayDate.getFullYear();
this.t_month = this._todayDate.getMonth()+1;
this.t_date = this._todayDate.getDate();
if( this._isDate(this.eCont.value) ){
/([\d]*)\-([\d]*)\-([\d]*)/.exec(this.eCont.value)
this._selectedDate = new Date(RegExp.$1,(RegExp.$2-1),RegExp.$3);
}
else{this._selectedDate = new Date();}
this.year = this._selectedDate.getFullYear();
this.month = this._selectedDate.getMonth()+1;
this.date = this._selectedDate.getDate();
if(this.top.document.dateDiv == undefined){
this.dd = this.top.document.createElement("DIV");
this.dd.obj = this;
this.dd.className = "WdateDiv";
this.dd.innerHTML = this._createPickerHTML();
var tmpInputs = this.dd.getElementsByTagName('input');
this.dd.mInput = tmpInputs[0];
this.dd.yInput = tmpInputs[1];
this.dd.dDiv = this.dd.getElementsByTagName('div')[3];
this._yminputKeydown = function(){
var evt = $d.obj.top.event;
var k =(evt.which==undefined)?evt.keyCode:evt.which;
if( !((k>=48 && k<=57) || k==8 || k==46 || k==37 || k==39) ){evt.returnValue=false;}
}
this.dd.mInput.attachEvent('onkeydown',this._yminputKeydown);
this.dd.yInput.attachEvent('onkeypress',this._yminputKeydown);
this.dd.mInput.onchange = this.dd.yInput.onchange = function() {$d.obj.redraw();};
this.dd.mInput.onfocus = this.dd.yInput.onfocus = function() {this.className='yminputfocus';};
this.top.document.body.insertAdjacentElement('afterBegin', this.dd);
this.top.document.dateDiv = this.dd;
var hasCss = false;
var tempHref1,tempHref2;
tempHref1 = this.cssPath.replace(/[.][.][/]/g,'').toLowerCase();
for(var i=this.top.document.styleSheets.length-1; i>=0; i--){
tempHref2 = this.top.document.styleSheets[i].href;
if(tempHref2.substring(tempHref2.length-tempHref1.length).toLowerCase() == tempHref1){
hasCss = true;
break;
}
}
if(!hasCss){this.top.document.createStyleSheet(this.cssPath); }
}
else{
this.dd = this.top.document.dateDiv;
this.dd.obj.win = this.win;
this.dd.obj.top = this.top;
this.dd.obj.eCont = this.eCont;
this.dd.style.display = '';
this.dd.mInput.value = this.month;
this.dd.yInput.value = this.year;
this.dd.dDiv.innerHTML = this._createDateTable();
}
this._setPubVar();
var objxy = this.eCont.getBoundingClientRect();
var mm = $getAbsM(this.top);
var currWinSize = $getClientWidthHeight(this.top);
var ddTop = mm.topM + objxy.bottom;
var ddLeft = mm.leftM + objxy.left;
if((ddTop+parseInt(this.dd.offsetHeight) < (currWinSize.height) ) ||(ddTop-this.eCont.offsetHeight < this.dd.offsetWidth*0.8) )
{this.dd.style.top = this.top.document.body.scrollTop + ddTop;}
else{this.dd.style.top = this.top.document.body.scrollTop + ddTop - parseInt(this.dd.offsetHeight) - this.eCont.offsetHeight - 3;}
this.dd.style.left = this.top.document.body.scrollLeft + Math.min(ddLeft, currWinSize.width-parseInt(this.dd.offsetWidth)-5);
}
var str;
str = "<div id=pickerTitle>"
str += "<div style='float:left;margin:2px'><table cellspacing=0 cellpadding=0 border=0><tr><td rowspan=2>月份:<input onblur=\"if(this.value>12){this.value='12'}else if(this.value<1){this.value='1'};this.className='yminput'\" class='yminput' style='width:24px;' maxlength=2 value="+this.month+"></td><td><button onfocus='this.blur()' onclick=\"if(Number($d.mInput.value)<12){$d.mInput.value=Number($d.mInput.value)+1;$d.obj.redraw();}\">▲</button></td></tr><tr><td><button onfocus='this.blur()' onclick=\"if(Number($d.mInput.value)>1){$d.mInput.value=Number($d.mInput.value)-1;$d.obj.redraw();}\">▼</button></td></tr></table></div>";
str += "<div style='float:right;margin:2px'><table cellspacing=0 cellpadding=0 border=0><tr><td rowspan=2>年份:<input onblur=\"this.className='yminput'\" class='yminput' style='width:44px;' maxlength=4 value="+this.year+"></td><td><button onfocus='this.blur()' onclick=\"$d.yInput.value=Number($d.yInput.value)+1;$d.obj.redraw();\">▲</button></td></tr><tr><td><button onfocus='this.blur()' onclick=\"$d.yInput.value=Number($d.yInput.value)-1;$d.obj.redraw();\">▼</button></td></tr></table></div></div>";
str += "<div>";
str += this._createDateTable();
str += "</div><div align=right style='padding-top:2px'><input onclick=\"$d.obj.pickDate('" + this._toDate(this.t_year,this.t_month,this.t_date) + "')\" type=button value='今天 " + this._toDate(this.t_year,this.t_month,this.t_date) + "'></input></div>";
return str;
}WdatePicker.prototype._createDateTable = function () {
var str,firstDay,firstDate,lastDay,lastDate;
var i,j,k;
firstDay = new Date(this.year,this.month-1,1).getDay();
firstDate = 1 - firstDay;
lastDay = new Date(this.year,this.month,0).getDay();
lastDate = new Date(this.year,this.month,0).getDate();
str = "<table width=100% border=0 cellspacing=0 cellpadding=0 style='line-height:20px;border:#c5d9e8 1px solid;'>";
str += "<tr id=weekTitle align=center>";
for(i=0; i<7; i++){str += "<td>" + this.aWeekStr[i] + "</td>";}
str += "</tr>";
for (i=1,j=firstDate; i<7; i++) {
str += "<tr>";
for (k=0; k<7; k++){
if(j>=1 && j<=lastDate){
str += "<td align=center style='cursor:hand' onclick=\"$d.obj.pickDate('" + j + "');\" onmouseover=\"this.className='WdayOn'\" onmouseout=\"this.className='Wday'\"><span";
if((this.year==this.t_year)&&(this.month==this.t_month)&&(j==this.t_date)){
str += " style='color:blue;font-weight:bold'";
}
str += ">" + j + "</span>";
}
else{
str += "<td><span></span>";
}
j++;
str += "</td>";
}
str += "</tr>";
}
str += "</table>";
return str;
}
WdatePicker.prototype._isDate = function (sDate) {
return sDate.match(/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/);
}WdatePicker.prototype._toDate = function (y,m,d) {
if(y==null){y = this.year;}
if(m==null){m = this.month;}
if(d==null){d = this.date;}
return y+'-'+m+'-'+d;
}WdatePicker.prototype._setPubVar = function () {
this.top.$d = this.top.document.dateDiv;
$d = this.top.$d;
}WdatePicker.prototype.redraw = function () {
this.year = this.dd.yInput.value;
this.month = this.dd.mInput.value;
this.dd.dDiv.innerHTML = this._createDateTable();
}