Codefixer - ASP tutorials, resources and software
ASP.NET 3.5/2.0 Hosting – Click Here
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Wednesday 14 May
MembersPro PayPal - ASP Membership software

asp.netPRO “Best ASP.NET Host” – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Generate a Random Picture with ASP

If 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;
<!--#include virtual="/banner/banner.asp"-->

LinksPro - Directory  and Link  Management Software




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software