Photo Gallery with next and previous buttons

Discussion in 'ASP .Net' started by msnews, May 27, 2005.

  1. msnews

    msnews Guest

    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
     
    msnews, May 27, 2005
    #1
    1. Advertising

  2. msnews

    Guest

    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/csharpsample/default.aspx
     
    , May 27, 2005
    #2
    1. Advertising

  3. 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
    >
    >
    >
     
    =?Utf-8?B?bWF2cmljazEwMQ==?=, May 27, 2005
    #3
  4. msnews

    msnews Guest

    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.

    <> wrote in message
    news:...
    > 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/csharpsample/default.aspx
    >
     
    msnews, May 31, 2005
    #4
  5. msnews

    Guest

    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
     
    , May 31, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Psybar Phreak

    previous & next buttons

    Psybar Phreak, Oct 11, 2003, in forum: Perl
    Replies:
    3
    Views:
    495
  2. David
    Replies:
    1
    Views:
    387
    =?Utf-8?B?SEFSSSBQUkFTRCBCQVJV?=
    Oct 27, 2004
  3. Replies:
    0
    Views:
    267
  4. orjanz

    Wizard previous/next-buttons and validation

    orjanz, Jan 25, 2008, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    1,179
    Steven Cheng[MSFT]
    Jan 30, 2008
  5. Replies:
    1
    Views:
    250
    Randy Webb
    Feb 19, 2006
Loading...

Share This Page