写了个用户控件,其中用到jquery实现一个分页功能,用到代码
Code
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="MyWUC.ascx.cs" Inherits="MyWork.WebUserControl.MyWUC" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<script type="text/javascript" src="../JS/jquery.pager.js"></script>
<script type="text/javascript" src="../JS/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function SelectObject()
{
var sign = 0;
var typeSign = "<%=ClientType%>"; //从后台获取返结果的类型
var colnum = <%=ColNum%>; //从后台获取要返回的所在列数
var list = document.getElementsByTagName("input");
var strAll = "";
for(var i=0;i<list.length;i++)
{
if(list[i].type == "radio")
{
if(list[i].checked == true)
{
sign = 1;
var objValue = list[i].parentElement.parentElement; //获取当前选中行
switch(typeSign)
{
case "colnum": //返回指定列的内容
alert(objValue.cells(colnum).innerText);
break;
case "all": //返回所有列的内容
for(var j=1;j<objValue.cells.length;j++)
{
strAll += objValue.cells(j).innerText + "/";
}
alert(strAll);
break;
}
}
}
}
if(sign == 0)
{
alert("请先选择一条记录!");
}
}
$(document).ready(function() {
$("#pager").pager({ pagenumber: 1, pagecount: 15, buttonClickCallback: PageClick });
});
PageClick = function(pageclickednumber) {
$("#pager").pager({ pagenumber: pageclickednumber, pagecount: 15, buttonClickCallback: PageClick });
$("#result").html("Clicked Page " + pageclickednumber);
}
</script>
<div><br>
<asp:datagrid id="dgData" PageSize="3" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="选择">
<ItemTemplate>
<INPUT type="radio" value="选择" name="radioSelect" onclick="SelectObject()">
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid><br>
<div id="pager" ></div>
调用该控件的页面代码为:
Code
<%@ Page language="c#" Codebehind="test.aspx.cs" AutoEventWireup="false" Inherits="MyWork.test" %>
<%@ Register TagPrefix="uc1" TagName="MyWUC" Src="WebUserControl/MyWUC.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>test</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<link href="css/Pager.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src=JS/jquery-1.3.2.min.js/>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<div id="div_MyWUC" style="text-align:center;">
<uc1:MyWUC id="MyWUC1" runat="server"></uc1:MyWUC>
</div>
</form>
</body>
</HTML>
不知道何原因,用debugger跟断点进去以后总是在 $(document).ready(function() 这里报错,说不支持此对象或者方法,比较郁闷,该用window.onload = function() 这样子也是一样,什么原因?