Displaying different image on page refresh

   —   
This article shows you how to have different images every time the page is refreshed or viewed.
You can have several images you want to change on each visitor’s access. If you are using Portal engine, you can add a repeater to your homepage and set this repeater like this:

path: path to folder where the images are
order by: NEWID()
Select Top N documents: 1


and select appropriate transformation. You may need to create your own transformation. You can find useful information in our Developer's guide in  "Writing transformation" article.

If you are using ASPX templates, you may add the functionality directly to the template. E.g. in code behind you can generate a random number and then display certain image in accordance this number. Please see our Developer's guide for more information in "Adding custom code to the ASPX page template"

Or you can place a repeater to this template. Settings of the repeater will be the same as in the first case.


See also:

Applies to: Kentico CMS 3.x, 4.x
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.