views:

382

answers:

2

What I am talking about is like this website : http://www.ernesthemingwaycollection.com

It has a static wallpaper and a set of images that change from page to page, I want to implement a similar way of displaying random images from a set of images using ASP.NET.

EDIT : I want the image to stay the same in a session, and change from a session to another.

+2  A: 

The site you mentioned is not using a random set of images. They are coded into the html side of the aspx page.

You could place an asp Image control on your page. Then on the page's Page_Load function set the image to a random picture of your set.

protected void Page_Load(object sender, EventArgs e)
        {

            this.Image1.ImageUrl = "~/images/random3.jpg";
        }

You have different options on where to store the image set data. You could use a database and store the urls in a table. This would allow to use the built-in Random function found in SQL. Or you can save a XML file to the server, load that then use the Random .Net class to pick one of your xml nodes.

Personally i would recommend the Database solution.

EDIT: Because the server session is destroyed after 20mins you may want to look at using cookies so you can see the last random image they saw.

Lance Ingle
+2  A: 

If you just want to rotate a set number of images you could use the ASP.NET AdRotator control (at last, a use for it!).

If you want to do something fancier, considering using a jQuery slideshow such jQuery Cycle Plugin. There is also a slideshow control in the AjaxControlToolkit, which is easy to integrate.

Dan Diplo