| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 437 人关注过本帖
标题:[求助]奇怪问题,请高人指点。
只看楼主 加入收藏
china_dy
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-19
收藏
 问题点数:0 回复次数:1 
[求助]奇怪问题,请高人指点。

1、test1.aspx(asp.net 1.1)

<%@ Page language="c#" Codebehind="left.aspx.cs" AutoEventWireup="false" Inherits="left" %>
<html>
<head>
<title>test1</title>
<script language="JavaScript" src="LeftCalendar.js"></script>
<script language="JavaScript" type="text/javascript"></script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<SCRIPT language="javascript">
ShowCalendar()
</SCRIPT>
</body>
</html>
此文件在visual studio 2003 编译运行在ie6.0上能正常显示日历。

2、test2.aspx(asp.net 2.0)

<%@ Page language="c#" CodeFile="left.aspx.cs" AutoEventWireup="false" Inherits="left" %>
<html>
<head>
<title>test1</title>
<script language="JavaScript" src="LeftCalendar.js"></script>
<script language="JavaScript" type="text/javascript"></script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<SCRIPT language="javascript">
ShowCalendar()
</SCRIPT>
</body>
</html>
此文件在visual studio 2005 编译运行在ie6.0上不能正常显示日历,提示对象“ ShowCalendar()”不存在!。

3、test3.aspx(asp.net 2.0)

<%@ Page language="c#" CodeFile="left.aspx.cs" AutoEventWireup="false" Inherits="left" %>
<html>
<head>
<title>test1</title>
<script language="JavaScript" >
var gdCtrl = new Object();
var goSelectTag = new Array();
var gcGray = "#808080";
var gcToggle = "#FFFF00";
var gcred = "#FF0000";
var gcBG = "#F8F9EE";
var gcGreen = "#00FF00"

var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth()+1;
var giDay = gdCurDate.getDate();

function fSetDate(iYear, iMonth, iDay){
gdCtrl.value = iYear+"-"+iMonth+"-"+iDay;
}

function fSetSelected(aCell){
var iOffset = 0;
var iYear =parseInt(tbSelYear.value);//动态改变文本框的年
var iMonth = parseInt(tbSelMonth.value);//动态改变文本框的月

aCell.bgColor = gcBG;
with (aCell.children["cellText"]){
var iDay = parseInt(innerText);
if (color==gcGray)
iOffset = (Victor<10)?-1:1;
iMonth += iOffset;
if (iMonth<1) {
iYear--;
iMonth = 12;
}else if (iMonth>12){
iYear++;
iMonth = 1;
}
}
this.top.frames[2].location = "Schedule/SchedByDay.aspx?date="+iYear+"-"+iMonth+"-"+iDay;
}


function fBuildCal(iYear, iMonth) {
var aMonth=new Array();
for(i=1;i<7;i++)
aMonth[i]=new Array(i);

var dCalDate=new Date(iYear, iMonth-1, 1);
var iDayOfFirst=dCalDate.getDay();
var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();
var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;
var iDate = 1;
var iNext = 1;

for (d = 0; d < 7; d++)
aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++;
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++);
return aMonth;
}

function fDrawCal(iYear, iMonth, iCellHeight, iDateTextSize) {
var WeekDay = new Array("日","一","二","三","四","五","六");
var styleTD = " bgcolor='"+gcBG+"' valign='middle' align='center' height='"+iCellHeight+"' style='font-size:9pt "+iDateTextSize+" 宋体;";

with (document) {
write("<tr>");
for(i=0; i<7; i++)
write("<td "+styleTD+"color:purple'>" + WeekDay[i] + "</td>");
write("</tr>");

for (w = 1; w < 7; w++) {
write("<tr>");
for (d = 0; d < 7; d++) {
write("<td id=calCell "+styleTD+"cursor:hand;' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick='fSetSelected(this)'>");
write("<font id=cellText Victor='Liming Weng'> </font>");
write("</td>")
}
write("</tr>");
}
}
}

function fUpdateCal(iYear, iMonth) {
myMonth = fBuildCal(iYear, iMonth);
var i = 0;
for (w = 0; w < 6; w++)
for (d = 0; d < 7; d++)
with (cellText[(7*w)+d]) {
Victor = i++;
if (myMonth[w+1][d]<0) {
color = gcGray;
innerText = -myMonth[w+1][d];
}else{
if (myMonth[w+1][d] == giDay && iYear == giYear && iMonth == giMonth)
{
//color = ((d==0)||(d==6))?"blue":"black";
color = "red";
innerText = myMonth[w+1][d];
}
else
{
color = ((d==0)||(d==6))?"blue":"black";
innerText = myMonth[w+1][d];
}
}
}
}
//该函数动态改变年后引起表格中的变化
function fSetYearMon(iYear, iMon){
tbSelMonth.options[iMon-1].selected = true;
for (i = 0; i < tbSelYear.length; i++)
if (tbSelYear.options[i].value == iYear)
tbSelYear.options[i].selected = true;
fUpdateCal(iYear, iMon);//将改变厚的值传给fUpdateCal()以便以在表格中显示变化
}

function fPrevMonth(){
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;

if (--iMon<1) {
iMon = 12;
iYear--;
}

fSetYearMon(iYear, iMon);
}

function fNextMonth(){
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;

if (++iMon>12) {
iMon = 1;
iYear++;
}

fSetYearMon(iYear, iMon);
}

function ShowCalendar()
{
var gMonths = new Array("&nbsp;1月","&nbsp;2月","&nbsp;3月","&nbsp;4月","&nbsp;5月","&nbsp;6月","&nbsp;7月","&nbsp;8月","&nbsp;9月","10月","11月","12月");

with (document) {
write("<table border='0' bgcolor='#F8F9EE'>");
write("<TR>");
write("<td valign='middle' align='center'><input type='button' name='PrevMonth' value='<' style='height:18;width:18' onClick='fPrevMonth()'>");
write("&nbsp;<SELECT name='tbSelYear' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' style='font-color:#000080;width:50;border:1 solid #99CCFF; font-size:9pt; background-color:#F8F9EE' Victor='Won'>");
for(i=1900;i<=2100;i++)
write("<OPTION value='"+i+"'>"+i+"</OPTION>");
write("</SELECT>");
write("<select name='tbSelMonth' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' style='font-color:#000080;width:50;border:0 solid #99CCFF; font-size:9pt; background-color:#F8F9EE' Victor='Won'>");
for (i=0; i<12; i++)
write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");
write("</SELECT>");
write("&nbsp;<input type='button' name='PrevMonth' value='>' style='height:18;width:18' onclick='fNextMonth()'>");
write("</td>");
write("</TR><TR>");
write("<td align='center'>");
write("<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td><table border='0' cellspacing='0' width='100%' cellpadding='0'>");
fDrawCal(giYear, giMonth, 12, 12);
write("</table></td></tr></table>");
write("</td></TR></TABLE>");
fSetYearMon(giYear, giMonth)
}
}
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<SCRIPT language="javascript">
ShowCalendar()
</SCRIPT>
</body>
</html>
此文件中,把javascript文件内容直接放在test3.aspx上在visual studio 2005 编译运行在ie6.0上也能正常显示日历。

对于test2.aspx为什么在asp.net 2.0上不能正常显示,请高人指点,万分感谢!



附:LeftCalendar.js 文件
var gdCtrl = new Object();
var goSelectTag = new Array();
var gcGray = "#808080";
var gcToggle = "#FFFF00";
var gcred = "#FF0000";
var gcBG = "#F8F9EE";
var gcGreen = "#00FF00"

var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth()+1;
var giDay = gdCurDate.getDate();

function fSetDate(iYear, iMonth, iDay){
gdCtrl.value = iYear+"-"+iMonth+"-"+iDay;
}

function fSetSelected(aCell){
var iOffset = 0;
var iYear =parseInt(tbSelYear.value);//动态改变文本框的年
var iMonth = parseInt(tbSelMonth.value);//动态改变文本框的月

aCell.bgColor = gcBG;
with (aCell.children["cellText"]){
var iDay = parseInt(innerText);
if (color==gcGray)
iOffset = (Victor<10)?-1:1;
iMonth += iOffset;
if (iMonth<1) {
iYear--;
iMonth = 12;
}else if (iMonth>12){
iYear++;
iMonth = 1;
}
}
this.top.frames[2].location = "Schedule/SchedByDay.aspx?date="+iYear+"-"+iMonth+"-"+iDay;
}


function fBuildCal(iYear, iMonth) {
var aMonth=new Array();
for(i=1;i<7;i++)
aMonth[i]=new Array(i);

var dCalDate=new Date(iYear, iMonth-1, 1);
var iDayOfFirst=dCalDate.getDay();
var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();
var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;
var iDate = 1;
var iNext = 1;

for (d = 0; d < 7; d++)
aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++;
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++);
return aMonth;
}

function fDrawCal(iYear, iMonth, iCellHeight, iDateTextSize) {
var WeekDay = new Array("日","一","二","三","四","五","六");
var styleTD = " bgcolor='"+gcBG+"' valign='middle' align='center' height='"+iCellHeight+"' style='font-size:9pt "+iDateTextSize+" 宋体;";

with (document) {
write("<tr>");
for(i=0; i<7; i++)
write("<td "+styleTD+"color:purple'>" + WeekDay[i] + "</td>");
write("</tr>");

for (w = 1; w < 7; w++) {
write("<tr>");
for (d = 0; d < 7; d++) {
write("<td id=calCell "+styleTD+"cursor:hand;' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick='fSetSelected(this)'>");
write("<font id=cellText Victor='Liming Weng'> </font>");
write("</td>")
}
write("</tr>");
}
}
}

function fUpdateCal(iYear, iMonth) {
myMonth = fBuildCal(iYear, iMonth);
var i = 0;
for (w = 0; w < 6; w++)
for (d = 0; d < 7; d++)
with (cellText[(7*w)+d]) {
Victor = i++;
if (myMonth[w+1][d]<0) {
color = gcGray;
innerText = -myMonth[w+1][d];
}else{
if (myMonth[w+1][d] == giDay && iYear == giYear && iMonth == giMonth)
{
//color = ((d==0)||(d==6))?"blue":"black";
color = "red";
innerText = myMonth[w+1][d];
}
else
{
color = ((d==0)||(d==6))?"blue":"black";
innerText = myMonth[w+1][d];
}
}
}
}
//该函数动态改变年后引起表格中的变化
function fSetYearMon(iYear, iMon){
tbSelMonth.options[iMon-1].selected = true;
for (i = 0; i < tbSelYear.length; i++)
if (tbSelYear.options[i].value == iYear)
tbSelYear.options[i].selected = true;
fUpdateCal(iYear, iMon);//将改变厚的值传给fUpdateCal()以便以在表格中显示变化
}

function fPrevMonth(){
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;

if (--iMon<1) {
iMon = 12;
iYear--;
}

fSetYearMon(iYear, iMon);
}

function fNextMonth(){
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;

if (++iMon>12) {
iMon = 1;
iYear++;
}

fSetYearMon(iYear, iMon);
}

function ShowCalendar()
{
var gMonths = new Array("&nbsp;1月","&nbsp;2月","&nbsp;3月","&nbsp;4月","&nbsp;5月","&nbsp;6月","&nbsp;7月","&nbsp;8月","&nbsp;9月","10月","11月","12月");

with (document) {
write("<table border='0' bgcolor='#F8F9EE'>");
write("<TR>");
write("<td valign='middle' align='center'><input type='button' name='PrevMonth' value='<' style='height:18;width:18' onClick='fPrevMonth()'>");
write("&nbsp;<SELECT name='tbSelYear' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' style='font-color:#000080;width:50;border:1 solid #99CCFF; font-size:9pt; background-color:#F8F9EE' Victor='Won'>");
for(i=1900;i<=2100;i++)
write("<OPTION value='"+i+"'>"+i+"</OPTION>");
write("</SELECT>");
write("<select name='tbSelMonth' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' style='font-color:#000080;width:50;border:0 solid #99CCFF; font-size:9pt; background-color:#F8F9EE' Victor='Won'>");
for (i=0; i<12; i++)
write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");
write("</SELECT>");
write("&nbsp;<input type='button' name='PrevMonth' value='>' style='height:18;width:18' onclick='fNextMonth()'>");
write("</td>");
write("</TR><TR>");
write("<td align='center'>");
write("<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td><table border='0' cellspacing='0' width='100%' cellpadding='0'>");
fDrawCal(giYear, giMonth, 12, 12);
write("</table></td></tr></table>");
write("</td></TR></TABLE>");
fSetYearMon(giYear, giMonth)
}
}

搜索更多相关主题的帖子: 高人 
2006-05-19 10:10
china_dy
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-19
收藏
得分:0 
加上CodePage="936"就可以了。
2006-05-20 16:00
快速回复:[求助]奇怪问题,请高人指点。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019518 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved