![]() |
|
|
Generate a Random Picture with ASPIf you haven't read Generate a Random Picture (Part 1) you may want to. Below is the code that I use(used) for an advertising campaign by DiscountASP.NET. They wanted to rotate two 468x80 banner images. I set up a file located in a folder 'includes' called 'banner.asp'. Below is the code that I inserted into this file. I have used a virtual include to embed the code from banner.asp into all my pages on this site. You will notice that a random number between 1 and 2 is generated and depending on the value of 'RandomNumber' the SELECT CASE function will output one of the banners and it's link and alt tags. <%
Dim LowestNumber, HighestNumber LowestNumber = 1 HighestNumber = 2 RANDOMIZE RandomNumber = Int((HighestNumber-LowestNumber+1)*Rnd+LowestNumber) SELECT Case RandomNumber Case 1 %> <div align="right"><a href="http://www.discountasp.net/go/go.aspx?i=452"><img src="/images/banners/blue_3mofree_skits_468_60.gif" alt="FREE Install of ASP.NET Starter Kits!!" border="0"></a></div> <% Case 2 %> <div align="right"><a href="http://www.discountasp.net/go/go.aspx?i=453"><img src="/images/banners/nobrand_affordable_468x60_.gif" alt="ASP/ASP.NET Web Hosting: $10 & 3 months FREE!!" border="0"></a></div> <% End Select %>
Here's the code that embeds the include file;
Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|