网上下了一个别人可以用的calendar控件,测试了一下怎么都用不起来,大家帮忙看一下我的代码哪里有问题,谢谢啦<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataSet_fill.aspx.cs" Inherits="DataSet_fill" %>
<%@ Import Namespace="System.Data" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Example</title>
<script type="text/javascript" src="Calendar1.js"></script>
</head>
<body>
<form id="form1" runat="server">
<input id="date" type="text" onfocus="calendar()" />
</form>
</body>
</html>
js控件是这篇文章中所列的第一个控件
http://blog.csdn.net/jaylongli/article/details/4383365
<%@ Import Namespace="System.Data" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Example</title>
<script type="text/javascript" src="Calendar1.js"></script>
</head>
<body>
<form id="form1" runat="server">
<input id="date" type="text" onfocus="calendar()" />
</form>
</body>
</html>
js控件是这篇文章中所列的第一个控件
http://blog.csdn.net/jaylongli/article/details/4383365
calendar1.jsfunction calendar()
{
document.write("hello world");
}用上面的方法调用还是不行但是如果将这段代码直接写到html页面中,则可以正常运行,代码如下:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataSet_fill.aspx.cs" Inherits="DataSet_fill" %>
<%@ Import Namespace="System.Data" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>DataSet Example</title>
<script type="text/javascript">
function calendar()
{
document.write("hello world");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataGrid ID="dg_Data" runat="server"></asp:DataGrid>
</div>
<asp:Label ID="lblDate" runat="server"></asp:Label>
<asp:Calendar ID="calDate" runat="server" SelectionMode="DayWeek" OnSelectionChanged="CalendarChanged"></asp:Calendar>
<input id="date" type="text" onfocus="calendar()" />
</form>
</body>
</html>
这样的话,应该可以确定还是使用的方法不对,但是该怎么用呢?
也可以选择路径确保正确
打开脚本调试测试下载的脚本,提示calendar函数没有定义
但脚本里分明是有这个函数的啊
脚本源代码:function calendar() //主调函数
{
var e = window.event.srcElement; writeIframe();
var o = WebCalendar.calendar.style; WebCalendar.eventSrc = e;
if (arguments.length == 0) WebCalendar.objExport = e;
else WebCalendar.objExport = eval(arguments[0]); WebCalendar.iframe.tableWeek.style.cursor = WebCalendar.drag ? "move" : "default";
var t = e.offsetTop, h = e.clientHeight, l = e.offsetLeft, p = e.type;
while (e = e.offsetParent){t += e.offsetTop; l += e.offsetLeft;}
o.display = ""; WebCalendar.iframe.document.body.focus();
var cw = WebCalendar.calendar.clientWidth, ch = WebCalendar.calendar.clientHeight;
var dw = document.body.clientWidth, dl = document.body.scrollLeft, dt = document.body.scrollTop;
if (document.body.clientHeight + dt - t - h >= ch) o.top = (p=="image")? t + h : t + h + 6;
else o.top = (t - dt < ch) ? ((p=="image")? t + h : t + h + 6) : t - ch;
if (dw + dl - l >= cw) o.left = l; else o.left = (dw >= cw) ? dw - cw + dl : dl; if (!WebCalendar.timeShow) WebCalendar.dateReg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
else WebCalendar.dateReg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; try{
if (WebCalendar.objExport.value.trim() != ""){
WebCalendar.dateStyle = WebCalendar.objExport.value.trim().match(WebCalendar.dateReg);
if (WebCalendar.dateStyle == null)
{
WebCalendar.thisYear = new Date().getFullYear();
WebCalendar.thisMonth = new Date().getMonth()+ 1;
WebCalendar.thisDay = new Date().getDate();
alert("原文本框里的日期有错误!\n可能与你定义的显示时分秒有冲突!");
writeCalendar(); return false;
}
else
{
WebCalendar.thisYear = parseInt(WebCalendar.dateStyle[1], 10);
WebCalendar.thisMonth = parseInt(WebCalendar.dateStyle[3], 10);
WebCalendar.thisDay = parseInt(WebCalendar.dateStyle[4], 10);
WebCalendar.inputDate = parseInt(WebCalendar.thisDay, 10) +"/"+ parseInt(WebCalendar.thisMonth, 10) +"/"+
parseInt(WebCalendar.thisYear, 10); writeCalendar();
}
} else {
WebCalendar.thisYear = new Date().getFullYear();
WebCalendar.thisMonth = new Date().getMonth()+ 1;
WebCalendar.thisDay = new Date().getDate();
writeCalendar();
}
} catch(e) {
WebCalendar.thisYear = new Date().getFullYear();
WebCalendar.thisMonth = new Date().getMonth()+ 1;
WebCalendar.thisDay = new Date().getDate();
writeCalendar();
}
}
试试,应该就是路径问题了
路径肯定没问题
谁能帮我看一下ps:我的工程在这里可以下载到:http://download.csdn.net/detail/jonglin/4051582
但是chrome不行 会不会你浏览器问题啊 我的ie版本是ie8 你IE多少 会不会是版本问题呢