Storing Advertisements in a Database Table : AdRotator « ASP.net Controls « ASP.NET Tutorial






<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>AdRotator Database</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <asp:AdRotator
        id="AdRotator1"
        DataSourceID="srcAds"
        Runat="server" />

    <asp:SqlDataSource
        id="srcAds"
        ConnectionString="Server=.\SQLExpress;Integrated Security=True;
            AttachDbFileName=|DataDirectory|AdListDB.mdf;User Instance=True"
        SelectCommand="SELECT ImageUrl, Width, Height, NavigateUrl, AlternateText, Keyword, Impressions
            FROM AdList"
        Runat="server" />

    </div>
    </form>
</body>
</html>

AdList database table

Column Name            Data Type
Id                     Int (IDENTITY)
ImageUrl             Varchar(250)
Width                 Int
Height                 Int
NavigateUrl             Varchar(250)
AlternateText         NVarchar(100)
Keyword                 NVarchar(50)
Impressions             Int








3.28.AdRotator
3.28.1.AdRotator randomly display different advertisements in a page
3.28.2.AdRotator for displaying your ad (C#)
3.28.3.OnAdCreated event
3.28.4.Storing Advertisements in an XML File
3.28.5.Storing Advertisements in a Database Table
3.28.6.Using the AdRotator control as a banner ad