.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Change the Background image of webpage erverytime user visits.

Posted By: Mek     Posted Date: July 28, 2013    Points:5   Category :ASP.Net

I have a webpage in asp.net + c#, i want to Change Background Image every time user visits the webpage. I mean if "A" visits the site the background should be rose.jpg, on revisiting the same webpage the background should be "jasmine.jpg" & on 3rd time some other image.This rotation of images will be for 24 hour i.e. every time "A" visits the same webpage the background should change.I think this is ahieveable using cookie, but falling short in coding it. Please help me out it in coding this stuff.


Author: AntonyDurai             
Posted Date: July 29, 2013     Points: 20   

from HTML Page body tag set as run at server.

Like: <body id="bdy1" runat="server">

and server side code is:

protected void Page_LoadComplete(object sender, EventArgs e)
Random rnd = new Random();
int i = rnd.Next(1, 5);
switch (i)
case 1:
bdy1.Attributes.Add("style", "background:url(images/Bluehills.jpg);");
case 2:
bdy1.Attributes.Add("style", "background:url(images/Sunset.jpg);");
case 3:
bdy1.Attributes.Add("style", "background:url(images/Waterlilies.jpg);");
case 4:
bdy1.Attributes.Add("style", "background:url(images/Winter.jpg);");

if you have images in database get the random image from and display this same.

Author: Deco             
Posted Date: July 30, 2013     Points: 20   

you can make use of adrotator to display the image for each and every time the page renders.

Also there are many jquery plugins for image slide show.

Author: Akhil Raj       [Moderator]      
Posted Date: August 14, 2013     Points: 20   

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend