Implement news paging with ASP.NET

xiaoxiao2021-03-14  173

Public class baseinfo {public string id, summary, content, picture; public datetime publictime; PUBLIC dateTime

Public Stringbuilder Pagefoot = New StringBuilder ();

Public Baseinfo () {}

// Add public int Add () {...}

// Update public int update () {...} // Initialization public void init () {...}}

In this page, it is necessary to pass the two parameters. .aspx page = 1 & id = 1 nextat is the position of the next [Page], backat is the position of the previous [Page], and Pagefoot is an HTML form. I add Runat = Server code as follows: BaseinFodetail.aspx part of the code as follows: BaseInfo Info = new baseinfo (); info.id = request.queryString ["id"]; info.init ();

// Page // i: Calculation Sign "[Page]"

Int nextat = -4, i = 0, backat = 0; string [] tempcontent = new string [20]; do {nextat = 4; Nexttat = info.content.indexof ("[Page], nextat);

IF (nextat! = -1) {i ; TempContent [i] = info.content.substring (backat, math.abs (nextat-backat)); backat = nextat 6;}} while (nextat! = -1) INT CurrentPage = Convert.TOINT32 (Request.QueryString ["Page"]); if (i> 0) {info.content = TempContent [CurrentPage]; this.pagefoot.visible = true;} else this.pagefoot.visible = False; info.pagefoot.append ("a total" i.tostring () "page"); for (int J = 1; j <= i; j ) {info.pagefoot.append ("[href = 'baseinfoDetail .aspx Page = " J.TOString () " & id = " info.id " " j.tostring () "] ");} if (currentpage! = i) {CURRENTPAGE = 1; Info.pagefoot.append ("next page");

转载请注明原文地址:https://www.9cbs.com/read-129208.html

New Post(0)