Creating a Repeat Region with simple Previous and Next links
OK, so we're familiar with creating a Repeat Region, but what if we don't want to display all the records at once, but still want the user to be able to cycle through them? We need to create Previous and Next buttons.
Let's create a page with some dynamic data and apply a Repeat Region from the Server Behaviors floater.
We'll choose to only display five records at a time, as we don't want the page to get too long.
Click OK, and you'll see the Repeat Region applied to the page. What we need to do now is to create an item to be our Previous and Next links. I'm going to use simple text links, but you could use images as links if you liked.
I've decided to use "Next >>" as my Next link, and "<< Prev" as my Previous link - so I'll insert these under my Repeat Region.
In order to make these into active links I must highlight each one and apply a Server Behavior to them. I'll start with the Next link.
The Server Behavior we need to apply is called "Move To Next Record" and is under the "Move To Record" section in the Server Behaviors menu.
You'll see the Move To Next Record dialogue box, which looks like this
Be sure to check that the correct Recordset is selected, and click OK
Once done, you will see that your Next link turns blue, indicating that it is now a dynamic element.
You need to repeat the process for the Previous link, but this time selecting the Server Behavior called "Move To Previous Record"
Click OK and you will see that now both your links are dynamic elements. You can hit F12 and check them out if you like!
There's just a couple more things that we need to do. At the moment, the Next link will be displayed even if we're at the end of the recordset. In the same way, even when we're right at record number 1, the Previous link is displayed.
That's not very user friendly, so what we're going to do is have those links hidden in the circumstances where they just don't make sense.
Highlight your Next link, and apply the "Hide Region" Server Behavior. (It's right under the Repeat Region Server Behavior in the list).
You should be presented with the Hide Region dialogue box which looks like this
We need to select the "If Last Record" option. This will hide the Next link if the current record is the last one in the recordset.
Click OK, and you'll see your Next link is now flagged up as a hidden region.
We need to now do the same with the Previous link, but this time selecting the "If First Record" option. This will hide the Previous link if the current record is the first one in the recordset.
Click OK and that should be it! You document will show both links in blue, as they are dynamic elements, and they will both be flagged as hidden regions.
It's as simple as that. You could now experiment with some of the other Server Behaviors in the "Move To Record" menu. See if you can create a link to move to the last record in the recordset, and one to return to the first record. If you're feeling particularly adventurous, you could have a play with the Move To Specific Record server behavior. Go on! It's fun!