Tuesday, 3 April 2018

017 Asp.Net Adrotator

Adrotator

Adrotator is a  server site  control introducing Asp.Net. Adrotator display advertisement dynamically. Adrotator is not static, if there are more advertisement, advertisement comes one by one , when a page is postback . Adrotator display image with text, when click on Adrotator . Adrotator  redirect URL to the advertisers WebSite . It is a server side control simply  in use , it read XML file  to display advertisement. The XML has a specific format which can be read by  Adrotator.

Here is the most common attribute of the  Adrotator. 
  • Constructor : 
  1. Adrotator : Create a new instance of  adrotator. 
  •  Properties 
  1. BackColor : Get or Set background color of a adrotator. 
  2. BorderColor : Get or Set border color of a adrotator. 
  3. BorderStyle : Get or Set border style of a adrotator. 
  4. BorderWidth : Get or Set border with offer ad adrotator. 
  5. ClientID : Get the ID generated by server  in HTML ,to identify the control. 
  6. CssClass : Get or Set CSS class of the adrotator. 
  7. Enabled : Get or Set adrotator enabled /disabled , boolean indicator true or false. 
  8. ForeColor :  Get or Set fore color of the adrotator. 
 
  • Method 
  1. Databind  : Bind data with the data source .
  2. Findcontrol :Search for a server control with parameter to identify that control.

  • Event
  1. Disposed : Dispose the advertisement and release all the memories.
  2. Load : Raised event when control is load.
  3. Prerender : Raised event before control is render.
  4. AdCreated : Raised event when advetisement is created.

Adrotator work with particular XML format, the schema of the XML file content all information and URL link related to advertisement.

Below is the explanation of the XML tag

<  Ad > Starting Tag of an advetisement.
< ImageUrl >  The URL of the image source on advertisement display.
< NavigateUrl >  When click on the advertisement , user will be navigate to this URL.
< AlternateText >  A text to display on the tooltips , when user take is mouse on the advertisement.
< Keyword >  String to filter advertisement category.
<  Impressions > How many user like that advertisement.
< Caption >  Caption of the advertisement.

 Below is a XML file. Pillow is the example of the ad rotator with the help of the XML file.


XML File
xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>Demo1.png</ImageUrl>
<NavigateUrl>http://google.com</NavigateUrl>
<AlternateText>Advertisement of C# Course </AlternateText>
<Impressions>95</Impressions>
</Ad>
<Ad>
<ImageUrl>Demo2.png</ImageUrl>
<NavigateUrl>http://yahoo.com</NavigateUrl>
<AlternateText>Advertisement of Asp.Net Course</AlternateText>
<Impressions>54</Impressions>
</Ad>
<Ad>
<ImageUrl>Demo3.png</ImageUrl>
<NavigateUrl>http://bing.com</NavigateUrl>
<AlternateText>Advertisement of Sql Server</AlternateText>
<Impressions>554</Impressions>
</Ad>
</Advertisements>

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableViewState="false" %>
<%@ OutputCache Duration="60" VaryByParam="DropDownList1" %>

<!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></title>
</head>
         <body>
                     <form id="form1" runat="server">
                             <div>
                                     <asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/XMLFile.xml" />
                     </div>
                   </form>
         </body>
</html>

Default.aspx.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
         protected void Page_Load(object sender, EventArgs e)
         {
         }
}


Output

No comments:

Post a Comment

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...