I can do this in Javascript by pulling a series of thumbnails as an array. Then I know when I'm on the first photo, or the last, and can show controls based on that.
How can this efficiently be done on the server side using C#/ASP.NET MVC 3(razor)? For example, on my site here, is one photo, out of 19 photos. I'd like to add next/prev functionality.
Do I have to pull the entire array of photos, parse out the current photo, determine if it's first or last, then build next/prev buttons?
When there is a photo gallery, there is One photo from many photos, and when there is a concept like x items from y items in which x < y
, then we all think of paging. Photo gallery is almost like a grid with one item and two buttons for going to the next page and previous page. If you want to implement paging by yourself, there is no need to fetch all photos and compare them to the current photo to create next/previous buttons. All you have to do, is to cache current item index and the count of all photos, and on each rendering, calculate to see if you need to render next, previous, or next and previous buttons.