AdRotator for displaying your ad (C#) : AdRotator « ASP.net Controls « ASP.NET Tutorial

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » ASP.net Controls » AdRotator 
3.28.2.AdRotator for displaying your ad (C#)
File: MainAds.xml

<?xml version="1.0" encoding="utf-8" ?> 
<Advertisements>

  <Ad>
    <ImageUrl>yourImage.gif</ImageUrl>
    <NavigateUrl>http://www.java2s.com</NavigateUrl>
    <AlternateText>Java2s.com</AlternateText>
    <Impressions>1</Impressions>
  </Ad>

</Advertisements>


File: Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="AdRotatorTest" %>

<!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 runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:AdRotator id="Ads" runat="server" 
     Target="_blank" AdvertisementFile="~/MainAds.xml" OnAdCreated="Ads_AdCreated" />
        <br />
        <br />
        <br />
        <asp:HyperLink ID="lnkBanner" runat="server">HyperLink</asp:HyperLink></div>
    </form>
</body>
</html>


File: Default.aspx.cs


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class AdRotatorTest : System.Web.UI.Page
{
    protected void Ads_AdCreated(object sender, AdCreatedEventArgs e)
    {
        lnkBanner.NavigateUrl = e.NavigateUrl;
        lnkBanner.Text = "Click here for information about our sponsor: ";
        lnkBanner.Text += e.AlternateText;
    }
}
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.