page.ascx 文件
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="page.ascx.cs" Inherits="page" %>
<table cellpadding="0" cellspacing="0">
<tr>
<%
for (int i = 1; i <=this._PageCount; i++)
{
%>
<td style="border:1px #000 solid;">
<a href="Default.aspx?page1=<%=i.ToString() %>"><%=i.ToString() %></a>
</td>
<% }
%>
</tr>
</table>
page.ascx.cs文件
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class page : System.Web.UI.UserControl
{
protected int _PageCount;
protected void Page_Load(object sender, EventArgs e)
{
}
public int PageCount
{
get { return _PageCount; }
set { _PageCount = value; }
}
}
现在这个控件就可以用了
拖动这个控件到Default.aspx文件里
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register src="page.ascx" tagname="page" tagprefix="uc1" %>
<!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<uc1:page ID="page1" runat="server"/>
</form>
</body>
</html>
page 控件有个属性PageCount可是这样写
<uc1:page ID="page1" runat="server" page1="5"/> 但是不可以像asp那样写 <uc1:page ID="page1" runat="server" PageCount="<%=rs(0)%>"/>
那么我要解决这个问题要怎么样搞呢?
其实这个问题很简单,nnd自己笨死了,搞了很久
只要在 Default.aspx.cs写不就可以了
page1.page1=rs(0);