今天在网上看到一个功能非常强大的日期控件,但是人家需要money.在以前搞asp的时候曾经用过一个调用js的日期控件,所以就拿到asp.net中,来发挥他的作用,让它做个免费的,功能强大的日期控件.(可以拖动)
首先看看在asp.net中是如何实现调用js函数的.
demo:
<script language="c#" runat="server">
private void page_load()
{
Button1.Attributes.Add("onClick", "return valSubmit();");
}
</script>
<html>
<head>
<SCRIPT LANGUAGE=javascript>
</script>
</script>
</head>
<body>
<form runat="server">
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
<!-- Insert content here -->
</form>
</body>
</html>
这下你明白拉吧,其实当你onClick这个buttond 时候,他就return js中的valSubmit()函数.
就这么简单(这样你就可以在页面中添加个删除确认按钮就没问题拉.)
接下来就是把哪个
function valSubmit() { alert("hello ! overred")}
用哪个日期的js代码替换下来.
<!--
//-------------------------------------------
// 这是梅花雨做的一个日历 Javascript 页面脚本控件,适用于微软的 IE (5.0以上)浏览器
//=========================================== 参数设定部分
var bMoveable=true; //设置日历是否可以拖动
var _VersionInfo="overred 集成" //版本信息
//======================================== WEB 页面显示部分
var strFrame; //存放日历层的HTML代码
document.writeln('<iframe scrolling="no" id=meizzDateLayer Author=wayx frameborder=0 style="position: absolute; width: 200; height:250; z-index: 9998; display: none "></iframe>');
strFrame='<style>';
strFrame+='INPUT.button{BORDER-RIGHT: #ff9900 1px solid;BORDER-TOP: #ff9900 1px solid;BORDER-LEFT: #ff9900 1px solid;';
strFrame+='BORDER-BOTTOM: #ff9900 1px solid;BACKGROUND-COLOR: #fff8ec;font-family:宋体;}';
strFrame+='TD{FONT-SIZE: 9pt;font-family:宋体;}';
strFrame+='</style>';
strFrame+='<scr' + 'ipt>';
strFrame+='var datelayerx,datelayery; /*存放日历控件的鼠标位置*/';
strFrame+='var bDrag; /*标记是否开始拖动*/';
strFrame+='function document.onmousemove() /*在鼠标移动事件中,如果开始拖动日历,则移动日历*/';
strFrame+='{if(bDrag && window.event.button==1)';
strFrame+=' {var DateLayer=parent.document.all.meizzDateLayer.style;';
strFrame+=' DateLayer.posLeft += window.event.clientX-datelayerx;/*由于每次移动以后鼠标位置都恢复为初始的位置,因此写法与div中不同*/';
strFrame+=' DateLayer.posTop += window.event.clientY-datelayery;}}';
strFrame+='function DragStart() /*开始日历拖动*/';
strFrame+='{var DateLayer=parent.document.all.meizzDateLayer.style;';
strFrame+=' datelayerx=window.event.clientX;';
strFrame+=' datelayery=window.event.clientY;';
strFrame+=' bDrag=true;}';
strFrame+='function DragEnd(){ /*结束日历拖动*/';
strFrame+=' bDrag=false;}';
strFrame+='</scr' + 'ipt>';
strFrame+='<div style="z-index:9999;position: absolute; left:0; top:0;" onselectstart="return false"><span id=tmpSelectYearLayer Author=wayx style="z-index: 9999;position: absolute;top: 3; left: 19;display: none"></span>';
strFrame+='<span id=tmpSelectMonthLayer Author=wayx style="z-index: 9999;position: absolute;top: 3; left: 78;display: none"></span>';
strFrame+='<table border=1 cellspacing=0 cellpadding=0 width=200 height=144 bordercolor=#ff9900 bgcolor=#ff9900 Author="wayx">';
strFrame+=' <tr Author="wayx"><td width=200 height=23 Author="wayx" bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=200 Author="wayx" height=23>';
strFrame+=' <tr align=center Author="wayx"><td width=16 align=center bgcolor=#ff9900 style="font-size:12px;cursor: hand;color: #ffffff" ';
strFrame+=' onclick="parent.meizzPrevM()" title="向前翻 1 月" Author=meizz><b Author=meizz><</b>';
strFrame+=' </td><td width=60 align=center style="font-size:12px;cursor:default" Author=meizz ';
//strFrame+='onmouseover="style.backgroundColor=\'#FFD700\'" onmouseout="style.backgroundColor=\'white\'" ';
//strFrame+='onclick="parent.tmpSelectYearInnerHTML(this.innerText.substring(0,4))" title="点击这里选择年份"><span Author=meizz id=meizzYearHead></span></td>';
strFrame+='onmouseover="parent.tmpSelectYearInnerHTML(this.innerText.substring(0,4))" title="点击这里选择年份" ><span Author=meizz id=meizzYearHead></span></td>';
//strFrame+='onclick="parent.tmpSelectYearInnerHTML(this.innerText.substring(0,4))" ><span Author=meizz id=meizzYearHead></span></td>';
strFrame+='<td width=48 align=center style="font-size:12px;cursor:default" Author=meizz ';
strFrame+=' onmouseout="style.backgroundColor=\'white\'" onmouseover="parent.tmpSelectMonthInnerHTML(this.innerText.length==3?this.innerText.substring(0,1):this.innerText.substring(0,2))"';
strFrame+=' title="点击这里选择月份"><span id=meizzMonthHead Author=meizz></span></td>';
strFrame+=' <td width=16 bgcolor=#ff9900 align=center style="font-size:12px;cursor: hand;color: #ffffff" ';
strFrame+=' onclick="parent.meizzNextM()" title="向后翻 1 月" Author=meizz><b Author=meizz>></b></td></tr>';
strFrame+=' </table></td></tr>';
strFrame+=' <tr Author="wayx"><td width=200 height=18 Author="wayx">';
strFrame+='<table border=1 cellspacing=0 cellpadding=0 bgcolor=#ff9900 ' + (bMoveable? 'onmousedown="DragStart()" onmouseup="DragEnd()"':'');
strFrame+=' BORDERCOLORLIGHT=#FF9900 BORDERCOLORDARK=#FFFFFF width=200 height=20 Author="wayx" style="cursor:' + (bMoveable ? 'move':'default') + '">';
strFrame+='<tr Author="wayx" align=center valign=bottom><td style="font-size:12px;color:#FFFFFF" Author=meizz>日</td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>一</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>二</td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>三</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>四</td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>五</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>六</td></tr>';
strFrame+='</table></td></tr><!-- Author:F.R.Huang(meizz) http://www.meizz.com/ mail: meizz@hzcnc.com 2002-10-8 -->';
strFrame+=' <tr Author="wayx"><td width=200 height=150 Author="wayx">';
strFrame+=' <table border=1 cellspacing=2 cellpadding=0 BORDERCOLORLIGHT=#FF9900 BORDERCOLORDARK=#FFFFFF bgcolor=#fff8ec width=200 height=150 Author="wayx">';
var n=0; for (j=0;j<5;j++){ strFrame+= ' <tr align=center Author="wayx">'; for (i=0;i<7;i++){
strFrame+='<td width=20 height=20 id=meizzDay'+n+' style="font-size:12px" Author=meizz onclick=parent.meizzDayClick(this.innerText,0)></td>';n++;}
strFrame+='</tr>';}
strFrame+=' <tr align=center Author="wayx">';
for (i=35;i<39;i++)strFrame+='<td width=20 height=20 id=meizzDay'+i+' style="font-size:12px" Author=wayx onclick="parent.meizzDayClick(this.innerText,0)"></td>';
strFrame+=' <td colspan=3 align=right Author=meizz><span onclick=parent.closeLayer() style="font-size:12px;cursor: hand"';
strFrame+=' &nbs