ASP编程:带日期标注的日历控件
实现规模效益。与传统的用户拥有硬件软件所有权和使用权以及传统的应用服务商提供一对一的服务模式不同,ASP拥有应用系统所有权,用户拥有使用权,应用系统集中放在ASP的数据中心中,集中管理,分散使用,以一对多的租赁的形式为众多用户提供有品质保证的应用技术服务,实现规模效益。控件称号:CalendarwithDateMark版本:1.0
类型:HTMLComponent
运转需求:IE5(保举IE5.5或更高版本)、MSXML、ASP或ASP.NET(背景)
费用:收费
支持:不供应撑持
源代码:XMLScriptlet
------------------------------------------------------------------------
<public:attachevent="oncontentready"onevent="init()"/>
<public:propertyname="value"get="getValue"put="setValue"/>
<public:propertyname="stringValue"get="getStringValue"/>
<public:propertyname="mark"get="getCurrentMark"put="setCurrentMark"/>
<public:propertyname="markList"get="getMarkList"/>
<public:methodname="refresh"/>
<public:methodname="addMark"/>
<public:methodname="removeMark"/>
<public:methodname="removeAllMark"/>
<public:methodname="loadMark"/>
<public:methodname="saveMark"/>
<public:eventname="onvaluechange"id="vlcg"/>
<scriptlanguage="JScript">
//----------------------------------------------------------------
//HTMLComponent:Calendarwithdatemark(带工夫标注的日历控件)
//
//Version:1.0
//
//Request:MicrosoftIE5orup
//
//Author:JoJo
//
//LastRealse:5/9/2001
//
//Copyright:ThinkSpaceSoftTec
//
//Contact:thinkspace@163.net
//----------------------------------------------------------------
vardate=newDate();
varactiveDate=newDate();
varmarklist=newActiveXObject("Scripting.Dictionary");
functionWriteXMLToDictionary(xmldoc,dict,rewrite){
varxnodelist=xmldoc.documentElement.selectNodes("Mark");
if(rewrite)dict.RemoveAll();
for(vari=0;i<xnodelist.length;i++){
varxnode=xnodelist.item(i);
varxdate=xnode.selectSingleNode("MarkDate");
varxnote=xnode.selectSingleNode("Note");
//alert(xdate.text+","+xnote.text);
if(xdate.text&&xnote.text){
dict.item(xdate.text)=xnote.text;
}
}
}
functionpostxml(xmldoc,url){
varxmlhttp=newActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST",url,false);
xmlhttp.Send(xmldoc);
varxdoc=newActiveXObject("Microsoft.XMLDom");
xdoc.async=false;
xdoc.loadXML(xmlhttp.responseText);
return!!xdoc.documentElement.text;
}
functionsaveMark(url){
varxmldoc=newActiveXObject("Microsoft.XMLDom");
WriteDictionaryToXML(marklist,xmldoc);
if(postxml(xmldoc,url)){
refresh();
sendEvent();
returntrue;
}
returnfalse;
}
functionWriteDictionaryToXML(dict,xmldoc){
xmldoc.loadXML("<MarkList/>");
varkeys=(newVBArray(dict.Keys())).toArray();
for(vari=0;i<keys.length;i++){
try{
vard=newDate(keys);
}catch(e){
continue;
}
if(!dict.item(keys))continue;
varxmark=xmldoc.createElement("Mark");
varxmarkdate=xmldoc.createElement("MarkDate");
xmarkdate.text=dateToSortString(d);
varxnote=xmldoc.createElement("Note");
xnote.text=dict.item(keys);
xmark.appendChild(xmarkdate);
xmark.appendChild(xnote);
xmldoc.documentElement.appendChild(xmark);
}
}
functionloadMark(url,rewrite){
varxmldoc=newActiveXObject("Microsoft.FreeThreadedXMLDOM");
xmldoc.async=false;
xmldoc.load(url);
//alert(xmldoc.xml);
WriteXMLToDictionary(xmldoc,marklist,rewrite);
refresh();
sendEvent();
}
functionrefresh(){
fillCalendar(date);
}
functiongetCurrentMark(){
if(!getMark(activeDate))return"";
returngetMark(activeDate);
}
functionsetCurrentMark(markvalue){
addMark(activeDate,markvalue);
}
functiongetMarkList(){
returnmarklist;
}
functiondateToSortString(adate){
return(adate.getMonth()+1)+"/"+adate.getDate()+"/"+adate.getFullYear();
}
functiongetMark(adate){
if(marklist.Exists(dateToSortString(adate)))
returnmarklist.Item(dateToSortString(adate));
}
functionaddMark(adate,note){
if(!note)returnfalse;
try{
vard=newDate(adate);
marklist.item(dateToSortString(d))=note;
fillCalendar(date);
returntrue;
}catch(e){
returnfalse;
}
}
functionremoveMark(adate){
try
{
marklist.Remove(dateToSortString(adate));
fillCalendar(date);
}catch(e){
}
}
functionremoveAllMark(){
marklist.RemoveAll();
fillCalendar(date);
}
functionsendEvent(){
varoevent=createEventObject();
vlcg.fire(oevent);
}
functiongetStringValue(){
returnactiveDate.getFullYear()+"年"+(activeDate.getMonth()+1)+"月"+activeDate.getDate()+"日";
}
functiongetValue(){
returnactiveDate;
}
functionsetValue(invalue){
try{
vartdate=newDate(invalue);
activeDate.setFullYear(tdate.getFullYear(),tdate.getMonth(),tdate.getDate());
date.setFullYear(tdate.getFullYear(),tdate.getMonth(),tdate.getDate());
fillCalendar(date);
sendEvent();
}catch(e){
return;
}
}
functionfillCalendar(adate){
ynm.innerText=adate.getFullYear()+"年"+(adate.getMonth()+1)+"月";
vartempdate=newDate();
tempdate.setFullYear(adate.getFullYear(),adate.getMonth(),1);
varfirst=true;
for(vari=0;i<tblbd.rows.length;i++){
for(varj=0;j<tblbd.rows(i).cells.length;j++){
varcell=tblbd.rows(i).cells(j);
cell.innerHTML="";
cell.bgcolor="";
cell.title="";
cell.style.backgroundColor="";
if(tempdate.getDay()==j){
if(!first)continue;
cell.innerText=tempdate.getDate();
if(getMark(tempdate)){
cell.bgcolor="wheat";
cell.style.backgroundColor=cell.bgcolor;
vartt=getMark(tempdate);
if(tt.length<20)
cell.title=tt
else
cell.title=tt.substr(0,20)+"...";
}
if(tempdate.getDate()==activeDate.getDate()){
hightLightDate(cell);
}
tempdate.setFullYear(tempdate.getFullYear(),tempdate.getMonth(),tempdate.getDate()+1);
first=tempdate.getDate()>1;
}
}
}
}
functionhightLightDate(object){
vartds=tblbd.all.tags("TD");
for(vari=0;i<tds.length;i++){
if(tds(i)!=object){
tds(i).style.backgroundColor=tds(i).bgcolor;
tds(i).style.color=""
}else{
tds(i).style.backgroundColor="navy";
tds(i).style.color="white";
}
}
}
functionselectDate(){
vari=parseInt(window.event.srcElement.innerText);
if((!isNaN(i))&&(i<3000)){
hightLightDate(window.event.srcElement);
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i);
sendEvent();
}
}
functionmoveDate(){
vark=window.event.keyCode;
switch(k){
case37:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()-1);
break;
case38:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()-7);
break;
case39:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()+1);
break;
case40:
activeDate.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate()+7);
break;
}
date.setFullYear(activeDate.getFullYear(),activeDate.getMonth(),activeDate.getDate());
fillCalendar(date);
sendEvent();
}
functionsetActiveDate(){
vari=activeDate.getDate();
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i);
while((date.getMonth()!=activeDate.getMonth())||(date.getFullYear()!=activeDate.getFullYear())){
activeDate.setFullYear(date.getFullYear(),date.getMonth(),i--);
}
sendEvent();
}
functiongoNextMonth(){
date.setMonth(date.getMonth()+1,1);
setActiveDate();
fillCalendar(date);
}
functiongoNextYear(){
date.setFullYear(date.getFullYear()+1,date.getMonth(),1);
setActiveDate();
fillCalendar(date);
}
functiongoPriorYear(){
date.setFullYear(date.getFullYear()-1,date.getMonth(),1);
setActiveDate();
fillCalendar(date);
}
functiongoPriorMonth(){
date.setMonth(date.getMonth()-1,1);
setActiveDate();
fillCalendar(date);
}
//---------------------------------------------------------------------
vartbl=window.document.createElement("<TABLEstyle="border:solid1px;width:100%;height:100%;font-size:9pt"cellspacing=0>");
vartblhd=window.document.createElement("THEAD");
vartblbd=window.document.createElement("TBODY");
varanchorPriorYear=window.document.createElement("A");
anchorPriorYear.style.fontFamily="webdings";
anchorPriorYear.style.cursor="hand";
anchorPriorYear.innerText="7";
anchorPriorYear.title="上一年";
varanchorPriorMonth=window.document.createElement("A");
anchorPriorMonth.style.fontFamily="webdings";
anchorPriorMonth.style.cursor="hand";
anchorPriorMonth.innerText="3";
anchorPriorMonth.title="上一月";
varanchorNextMonth=window.document.createElement("A");
anchorNextMonth.style.fontFamily="webdings";
anchorNextMonth.style.cursor="hand";
anchorNextMonth.innerText="4";
anchorNextMonth.title="下一月";
varanchorNextYear=window.document.createElement("A");
anchorNextYear.style.fontFamily="webdings";
anchorNextYear.style.cursor="hand";
anchorNextYear.innerText="8";
anchorNextYear.title="下一年";
varynm=window.document.createElement("FONT");
ynm.style.width="60%";
ynm.style.fontWeight="bold";
varcpt=window.document.createElement("CAPTION");
tbl.appendChild(cpt);
tbl.appendChild(tblhd);
tbl.appendChild(tblbd);
functioninithead(){
cpt.style.backgroundColor="navy";
cpt.style.color="white";
cpt.style.textAlign="center";
cpt.style.cursor="defalut";
cpt.appendChild(anchorPriorYear);
cpt.appendChild(anchorPriorMonth);
cpt.appendChild(ynm);
cpt.appendChild(anchorNextMonth);
cpt.appendChild(anchorNextYear);
varrow=tblhd.insertRow();
row.align="center";
varweekStr=newArray("日","一","二","三","四","五","六");
for(vari=0;i<weekStr.length;i++){
varcell=row.insertCell();
cell.innerText=weekStr;
cell.style.borderBottom="solid1px";
cell.style.cursor="default";
cell.align="center";
}
}
functioninitbody(){
for(vari=0;i<6;i++){
varrow=tblbd.insertRow();
for(varj=0;j<7;j++){
varcell=row.insertCell();
cell.innerHTML="";
cell.style.cursor="default";
cell.align="center";
}
}
}
functioninit(){
inithead();
initbody();
element.appendChild(tbl);
fillCalendar(date);
tblbd.attachEvent("onclick",selectDate);
tblbd.attachEvent("onkeydown",moveDate);
anchorPriorYear.attachEvent("onclick",goPriorYear);
anchorPriorMonth.attachEvent("onclick",goPriorMonth);
anchorNextMonth.attachEvent("onclick",goNextMonth);
anchorNextYear.attachEvent("onclick",goNextYear);
sendEvent();
}
</script>
asp,jsp,php是web开发的三大技术,asp简单易用且有microsoft做靠山,jsp功能强大是因为有java支持,php则开源跨平台.在国内,asp应用范围最广,jsp发展势头最猛,php则处于劣势.这可能与公司的支持以及技术的培训有关. 运用经典的例子。并且自己可以用他来实现一些简单的系统。如果可以对他进行进一步的修改,找出你觉得可以提高性能的地方,加上自己的设计,那就更上一个层次了,也就会真正地感到有所收获。 作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。 ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题: 完全不知道到底自己学的是什么。最后,除了教程里面说的几个例子,还是什么都不会。 ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题: 下面简单介绍一下我学习ASP的方法,希望对想学习ASP的朋友有所帮助... 代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。
页:
[1]