[thelist] Help Using OnPreRender

Casey aspnet at thecrookstons.com
Mon Dec 12 19:51:50 CST 2005


(asp.net with vb.net....)

I am breaking new ground here, so please forgive me as I forge ahead.
Before I go any further I should add that I have searched Google extensively
and found no help.  I am gathering what little I know from:


Here's my problem:

I am trying to implement a simple paging function... the current page only
shows items 1 - 15 of 95 items.  At the bottom of a page is a set of links
that looks like this:

<< Back   1 | 2 | 3 | 4  Forward >>

The set of links is rendered in a sub:
BuildPagingLinks(ViewState("totalPages")) where ViewState("totalPages") is
the total number of pages to be rendered.

Back, Forward, and the numbers are all linkbuttons.  There is ViewState
variable, ViewState("onPage") which keeps track of what page we are
currently viewing.  The "Back" linkbutton posts back a value of
ViewState("onPage")-1, while the number 4 simply posts back the value of 4,

What I need to do is render whatever page we are currently looking at in
bold.  So, it we are looking at page one, it would look like this:

<< Back   <b>1</b> | 2 | 3 | 4  Forward >>

The trouble is, when a user clicks on one of the linkbuttons and the page
postsback and re-renders, the function that builds the links is ALWAYS
triggered before ther function that handles the postback commands from the
linkbuttons.  Why is that bad?  Because the page that is bolded in the set
of links is ALWAYS one page behind what we are actually looking at.

Now, I think my solution lies in working with the OnPreREnder method - but I
am unsure of how exactly to use it.  Jason Handby offered the
following solution:

      Protected Overrides Sub OnPreRender(e As EventArgs)
      End Sub

This loads the links just as it should, but then fails to autopost back any
of the linkbubttons.  I'm close - but I just can't quite nail it.  I've
attached the code if you want to be bored.  and here's the page online:



More information about the thelist mailing list