This tutorial will show how to implement random advertisements on your website, using the AdRotator Control, and how to capture the number of clicks for each. VB version.

Random rotation of advertisements is made very easy in Visual Studio. This tutorial shows how to implement this control, and also a way of monitoring the number of clicks each ad receives.
This tutorial uses graphics to display clickable advertisements.

Create New Folder in Solution Explorer for images. Copy to this folder existing images to be used as advertisements.

Then create an XML file to list the ads:

Create a web page to display the ads, add the AdRotator Control, and add the XML file (App_Data/ as the Data Source. The ASP should look something like this:

One way of tracking ad clicks is to write them into an XML file. To do this, you’ll need to redirect the user to a page that counts the click before it redirects them to the advertisement website.

Change NavigateUrl in the XML file (

Now add another XML file – AdResponse.xml – to count the number of clicks.

Now create the redirection page, AdRedirector.aspx

To read the click data from XML, create another ASPX page – ViewAdData.aspx
Add XmlDataSource from the toolbox and choose AdResponses.xml (containing click data) as Data Source.
Also add GridView from toolbox and choose the Data Source. The code should be something like this:

Download Source Files