Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- From: "John Rivers" <first10@xxxxxxxxxxxxxx>
- Date: 26 Aug 2005 16:13:29 -0700
with pleasure,
this is exactly ten lines of code (exluding the function declaration
and html stuff)
excuse the classicasp, i had it handy
Function PageControl(PageNumber, PageCount)
Const PropName = "PageNumber"
%><table width="100%" cellpadding="4" cellspacing="0"
bgcolor="#EEEEEE">
<!---->
<tr>
<td nowrap><%="Page " & PageNumber & " of " & PageCount%></td>
<td align="right" nowrap><b><%
Dim URL
URL = ThisPage & StripQueryString(Request.QueryString, PropName)
If PageNumber > 1 Then
%>[<a href="<%=HTML(URL & QPX(PropName, 1))%>">First</a>]
[<a href="<%=HTML(URL & QPX(PropName, PageNumber - 1))%>">Prev</a>]<%
Else
%><span style="color:#CCCCCC">[First]
[Prev]</span><%
End If
%> <%
If PageNumber < PageCount Then
%>[<a href="<%=HTML(URL & QPX(PropName, PageNumber + 1))%>">Next</a>]
[<a href="<%=HTML(URL & QPX(PropName, PageCount))%>">Last</a>]<%
Else
%><span style="color:#CCCCCC">[Next]
[Last]</span><%
End If
%></b></td>
</tr>
<!---->
</table><%
End Function
(HTML is convenience function to save typing Server.HTMLEncode etc.)
(QPX is shorthand for Server.URLEncode(name) & "+" &
Server.URLEncode(value) & "&")
(StripQueryString returns the given querystring minus the given
parameter)
and of course i would have done the paging logic in a stored procedure
rather than repeatedly transferring piles of data about for no reason
like that idiotic "datagrid" control does
which i can show you here:
CREATE proc spTestCursorPagination
@start int
, @size int
as
--
declare CRS cursor scroll read_only for select recordid from junk
(tablock) order by recordid
declare @index int
declare @recordid int
--
create table #temp (
orderid int primary key identity
, recordid int
)
set nocount on
set @index = 0
open CRS
--
while @index < @size
begin
if @index = 0
fetch absolute @start from CRS into @recordid
else
fetch next from CRS into @recordid
insert into #temp with (tablockx) (recordid) values (@recordid)
set @index = @index + 1
end
--
close CRS
deallocate CRS
--
select junk.* from junk (tablock)
inner join #temp (tablock)
on junk.recordid = #temp.recordid
order by #temp.orderid
--(end)
and i didn't need to read a book to do that
i just used my brain and 20 minutes
plus if you test my solution on a db of 10,000,000
records it will run faster than his junk with 10,000
records and use much less ram and cpu and network resources
www.15seconds.com is useful but most of the articles are total tripe
welcome to the layer cake son
VB Programmer wrote:
> Can you post 10 sample lines of code to do this? Just wondering what it
> would look like from your vantage pt.
>
> Thanks!
>
> "John Rivers" <first10@xxxxxxxxxxxxxx> wrote in message
> news:1125094378.931114.81020@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > http://www.15seconds.com/Issue/030812.htm?voteresult=1
> >
> > poor guy worked his heart out, just to make a page control
> >
> > and then they published it
> >
> > ha ha ha ha ha
> >
> > to "help" others
> >
> > ha ha ha ha ha ha
> >
> > just imagine the face of a newbie looking at that mountain of code
> >
> > apparently he researched how to do it in books
> >
> > my god i would love to watch this guy tie his shoelaces
> >
> > it must take hours and involve lots of complex mathematics
> >
> > ha ha ha ha
> >
> > maybe the poor guy's hourly rate is so low he has to overcomplicate
> > everything just to pay the rent
> >
> > ha ha ha ha
> >
> > imagine him working through the night
> > "i'll make the best page control, ever!"
> >
> > i've got it! he hates newbies ... so he publishes ridiculous
> > articles to demoralise them and drain their energy
> >
> > doesn't tell them that a generic page control is just 10 lines
> > of code that a monkey could write HE'S EVIL
> >
> > extract from his article:
> >
> > "Effectively showing code so it confuses newbies is a main objective
> > in writing almost all my web articles. Showing 20 lines of code in an
> > article is unbearable but showing 10,000 certainly can be helpful.
> > Writing good code, is a commonly employed solution, that I do not
> > recommend."
> >
.
- Follow-Ups:
- Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- From: Bruce Barker
- Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- From: Juan T. Llibre
- Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- References:
- This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- From: John Rivers
- Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- From: VB Programmer
- This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- Prev by Date: Re: Server.Redirect to post to another page question
- Next by Date: Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- Previous by thread: Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- Next by thread: Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- Index(es):
Relevant Pages
|
Loading