Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Photo Gallery with next and previous buttons

Reply
Thread Tools

Photo Gallery with next and previous buttons

 
 
msnews
Guest
Posts: n/a
 
      05-27-2005
Hi All,

My client has following request. I am not sure how to do it.

Dynamically from database, we are getting set of images names. Now we want
to display them with next and previous buttons.
I am able to pull all the information from database and put it in javascript
array. Now using two functions for next and previous button, I am able to
browse through the images.

The problem is, when I click on next and previous, it's not hitting the
server (as the information is available at the client). But we want it to
connect it to the server so that the page gets refreshed with new paid ads.

Is it possible to acheive that without hitting the database. Please help me.
It's very urgent.


Thanks,
Anil


 
Reply With Quote
 
 
 
 
garethdjames@gmail.com
Guest
Posts: n/a
 
      05-27-2005
OK, you have got a few options here,

Postback to the server with each click of next or previous, the image
names and text can be stored in the session, or viewstate for better
scalability.

or, do as you are doing now with it all client side, but use an
javascript asynchronous event to reload (or replace) the adverts, the
ajax framework would be a good place to start,

A .Net wrapper for ajax has been release (not open source as yet),

http://ajax.schwarz-interactive.de/c...e/default.aspx

 
Reply With Quote
 
 
 
 
=?Utf-8?B?bWF2cmljazEwMQ==?=
Guest
Posts: n/a
 
      05-27-2005
If you just want to get the ad from the server and not all the stuff on the
page then I'd place the ad in an iframe (If I can force the users to use IE)
and reload the iframe location on button click.



"msnews" wrote:

> Hi All,
>
> My client has following request. I am not sure how to do it.
>
> Dynamically from database, we are getting set of images names. Now we want
> to display them with next and previous buttons.
> I am able to pull all the information from database and put it in javascript
> array. Now using two functions for next and previous button, I am able to
> browse through the images.
>
> The problem is, when I click on next and previous, it's not hitting the
> server (as the information is available at the client). But we want it to
> connect it to the server so that the page gets refreshed with new paid ads.
>
> Is it possible to acheive that without hitting the database. Please help me.
> It's very urgent.
>
>
> Thanks,
> Anil
>
>
>

 
Reply With Quote
 
msnews
Guest
Posts: n/a
 
      05-31-2005
Hello Sir,
I tried with viewstate (using arraylist) and it worked. Thanks for that.
But I seem to have some problem. Problem is, even though I am using
viewstate, for every click on next or previous button, it's still trying to
get the data from database. I am using asp:hyperlink for that.

Basically my url for the photo album is as follows
photo.aspx?albumid=20&photoid=6

And my database call and population of viewstate is within
if (!Page.IsPostBack)

Actually, what we are looking for is, whenever the albumid changes then only
refresh the viewstate (get data from database). If only photoid is changing
then use the existing viewstate to link the next, previous links.

Please help me, let me know what mistake i am doing.

Thanks,
Anil.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> OK, you have got a few options here,
>
> Postback to the server with each click of next or previous, the image
> names and text can be stored in the session, or viewstate for better
> scalability.
>
> or, do as you are doing now with it all client side, but use an
> javascript asynchronous event to reload (or replace) the adverts, the
> ajax framework would be a good place to start,
>
> A .Net wrapper for ajax has been release (not open source as yet),
>
> http://ajax.schwarz-interactive.de/c...e/default.aspx
>



 
Reply With Quote
 
garethdjames@gmail.com
Guest
Posts: n/a
 
      05-31-2005
The problem that you using an asp:hyperlink, this control does not
cause a post back,

If the page is not a post back (i.e normal load) then load the data
from the DB into an array and store it in the ViewState, then call a
function in the code behind class that renders the appropriate picture,
pass an argument of 0 (zero) to the function, indicating to display the
first picture,

use asp:LinkButton instead of hyperlink, this will cause post back,

create an event handler for each of the LinkButtons (next and
previous), do this by double clicking on the linkbutton, add the
following code (sorry its in c#)

private void NextButton_Click(object sender, System.EventArgs e)
{
int index = (int)ViewState["index"];
index = index + 1;
ViewState["index"] = i;
RenderPicture(index);
}

(where RenderPicture is your function that acts on the viewstate)

also in the RenderPicture function you can disable the next or previous
linkbutton depending if you are at the start or the end of the array,

if you still have trouble zip the code up and mail it to me and I'll
sort it out

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wizard previous/next-buttons and validation orjanz ASP .Net Web Controls 3 01-30-2008 02:41 AM
GridView Next / Previous buttons shapper ASP .Net 1 03-22-2007 02:42 PM
Hide the next previous buttons in wizard control Roger23 ASP .Net 0 03-13-2006 08:59 PM
implementing record browser (next previous buttons) David ASP .Net 1 10-27-2004 11:23 AM
previous & next buttons Psybar Phreak Perl 3 10-13-2003 09:57 PM



Advertisments