What's the best way to show a random image in ASP.NET? -


What I'm talking about is like this website:

There is a static wallpaper in it and There is a set of images that vary from page to page, I want to apply the same way to display random images from a set of images using ASP.NET.

Edit : I remain the same image in one session and change from session to second.

The site you are using is not a random set of images by using it. They are coded in the HTML side of the aspx page

You can put ASP image controls on your page. Then set the image in the page_load function in a random picture of your set.

  Secure Zero Page_load (Object Sender, EventAgds E) {this.Image1.ImageUrl = "~ / images / random3 .jpg"; }  

You have different options where to store image set data. You can use a database and store the URL in the table. This will allow the use of the built-in function found in SQL. Or you can save an XML file to the server, load it, then select one of your XML nodes to randomize it. Use net class.

Personally, I would recommend the database solution.

Edit: Because the server session is destroyed after 20mins, you may want to try using cookies so that you can see the last random image seen.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -