分享
 
 
 

asp.net中调用&#106avascript函数实现多功能日期控件示例

王朝asp·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

今天在网上看到一个功能非常强大的日期控件,但是人家需要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>&lt;</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>&gt;</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

[1] [2] [3] [4] [5] [6] [7] 下一页

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有