Create an ASP universal paging class (1)

xiaoxiao2021-03-05  22

From the beginning of learning to use ASP, there are still many programs, the most headache is written data paging, each time due to several variable names or several parameters, which requires which paragraph every time The lengthy and complicated paging code, the code is long, which makes the program's readability, easy to travel, the debug is not missing for a long time, so slowly I start using some online supplied paging functions or panesses. It is indeed a lot of things, but the usual functions and classes are also encapsulated on the data display section. Every time I want to change the function or class itself, it is not convenient to use it. I have been complicated enough to write the paging it yourself. Don't say others. So, I have time I wrote a paging class yesterday, I feel good, I don't want to use eggs. I share my experience with you (talk about experience, thinking about it). Here I don't want to say the principle of paging, anyway, everyone knows, I have to talk about it in depth, I will not. Ha ha. First, the goal of creating a page class before writing, I thought, what kind of class I want to write, I think about the previous write process, the most annoying, which is the complex pagination code for each time you have to write. The biggest trouble is only a few variable names every time. So the first thing to implement is to put this package, the second is to encapsulate the navigation bar of the paging, the third, not used to encapsulate the data display parts, which is not convenient to program, For those who have different display effects every time, it is more troublesome than yourself. So my purpose is some simple packages for RecordSet.

Second, the creation process, the first attribute I wrote, is to return a processed Recordse Public Property Get GETRS () set xd_rs = server.createObject ("AdoDb.Recordset") xd_rs.pagesize = Pagesize XD_RS.Open XD_SQL, XD_CONN , 1,1 If not (XD_Rs.eof and XD_RS.BOF) Then If int_curpage> XD_RS.PageCount role Then int_curpage = XD_RS.PageCount End If XD_Rs.AbsolutePage = int_curpage End If Set GetRs = XD_RS End property this property is more, according to Specify the current surface of Recordset and the first record of the pointer point to the current page, this should be the core of the entire class completes the paging. Of course, some of the parameters are obtained by other properties, so this is here to introduce one this The basic parameters of the class ============================================== 'GetConn gets database connection' '=========================================== == Public property let getConn (obj_conn) set xd_conn = obj_conn end proty '=================================== =========== 'getSQL get query statement' '================================== ============== Public property let getsql xd_sql = str_sql end proty '=======================

========================= 'Pagesize property' Sets the page size of each page '============= =========================================== p l p i i n n n n n i i @ d x (int_PageSize) Else str_error = str_error & "parameter PageSize incorrect" ShowError () End If End Property Public Property Get PageSize If XD_PageSize = "" or (not (IsNumeric (XD_PageSize))) Then PageSize = 10 Else PageSize = XD_PageSize End Several of IF End Property is the need to specify the parameters in the process of using the class. I used to judge each incoming parameter when writing attributes. It is the robust, but later. I want to go, this is not necessary to talk to the ASP, it is not enough to speed up the speed, as for why, I think you will find it during use, it is better not to add. This is also after I have been thinking, I only retain some necessary verification.

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

New Post(0)