Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rotating header image asp.net 2.0 1

Status
Not open for further replies.

wallm

Programmer
Apr 4, 2005
69
GB
can anyone help with a script to rotate the top 800x180 pixel image in a website on page load.
Should I use the Adrotator or is there a simple piece of script that works?

thanks.
 
You want it to continuously rotate? You might want to ask this in the JavaScript forum.
 
Hi no just every time the page is refreshed.
 
I'd use the AdRotator control


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Haven't heard of that, but you can probably use GDI+ (although it might be tricky)
 
yeah might just use the adrotator... why did microsoft call the contorl the adrotator, perhaps a name like imagerotator might have been more appropriate as in my case the image isn't an ad.

thanks.
 
jshurst - I think the OP means rotate the image as in change the image that is being displayed rather than change the orientation of the image.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ah, I'm way off then. I actually had a function for that then ;-)

Create a folder to hold the images, then give each a sequence name (like Image1.jpg, Image2.jpg) Then put the following in the page_load.

Code:
Const NUMBER_OF_IMAGES As Integer = 9
Dim RandomGenerator As Random
Dim intRandomNumber As Integer

' Create and init the randon number generator
RandomGenerator = New Random

' Get the next random number
intRandomNumber = RandomGenerator.Next(1, NUMBER_OF_IMAGES + 1)

' Use random number to build the path to our random image
picMain.ImageUrl = "images/pic" & intRandomNumber & ".jpg"

I thought it was a little weird for an image to "rotate" everytime the page loaded :-D
 
Yeah, that's another good method (the AdRotator control would work on a similar basis but you would probably create a dynamic XML source for it). You could also extend your function slightly so that it can be run from any folder (although you'd maybe want a check to see if the file extension was a valid image extension):
Code:
        Dim FileList() As String = System.IO.Directory.GetFiles("C:\inetpub\[URL unfurl="true"]wwwroot\testsite\images")[/URL]
        Dim RandomGenerator As Random
        Dim intRandomNumber As Integer

        ' Create and init the random number generator
        RandomGenerator = New Random

        ' Get the next random number
        intRandomNumber = RandomGenerator.Next(1, FileList.GetUpperBound(0) + 1)

        ' Use random number to build the path to our random image
        picMain.ImageUrl = "images/" & Path.GetFileName(FileList(intRandomNumber))


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top