Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha



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
%>&nbsp;<%
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."
> >

.



Relevant Pages

  • Re: Is this good use of Properties?
    ... Overloads can also be inferred by the compiler ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... >I could declare it as static but only one instance of this class will ever ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Any benefit for fixed size hashtable?
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... My understanding is that fix size declaration may provide better memoery allocation internally, but I am not sure whehter I will really gain anything in performance. ... Since whenever I declare fix size, I always start a timed bomb in the future which may explode if my data items go beyond that size and I forget to handle it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Different Row Counts From Two Virtually Identical Queries
    ... "Bruce Rose" wrote in message ... > insert into ##junk values ... > declare @sLastName nvarchar ... Any insight into this anomaly is appreciated. ...
    (microsoft.public.sqlserver.programming)
  • Re: Is this good use of Properties?
    ... I could declare it as static but only one instance of this class will ever ... What are some of your reasons for saying the VB compiler is brain dead? ... > Find great Windows Forms articles in Windows Forms Tips and Tricks ... >> public string URL ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: a Flash methods question?
    ... What a junk. ... You could have at least considered to declare `movieplayed'. ... One does not declare, within a function, any global variables that it ...
    (comp.lang.javascript)

Loading