Use of adrotator in asp.net counting number of clicks on banner ad
95An Ad rota-tor in asp.net is used to create advertisements like banners and add responses to them. For eg we can know how many time the banner is clicked just like google ad sense does.
How to create it
open a new website in visual studio dot net file-> new website name it advertisehere.aspx
right click on solution explorer and add new folder. Create three images in paint a1.bmp a2.bmp a3.bmp
add these images to the images folder ..right click on images folder and select "add exisiting item."
create an xml file by right clicking in solution explorer .."add new item" select xml file and put the following code.
xml file
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<!-- The URL for the ad image -->
<ImageUrl>images/a1.bmp</ImageUrl>
<!-- The URL the ad redirects the user to -->
<NavigateUrl>http://www.microsoft.com</NavigateUrl>
<!-- The alternate text for the image -->
<AlternateText>Visit Microsoft's Site</AlternateText>
<!-- The relative number of times this ad should appear -->
<!-- compared to the others -->
<Impressions>80</Impressions>
<!-- The topic of this ad (used for filtering) -->
<Keyword>ProductInfo</Keyword>
</Ad>
<Ad>
<ImageUrl>images/a2.bmp</ImageUrl>
<NavigateUrl>http://www.microsoft.com/technet</NavigateUrl>
<AlternateText>Support for IT Professionals</AlternateText>
<Impressions>40</Impressions>
<Keyword>Support</Keyword>
</Ad>
<Ad>
<ImageUrl>images/a3.bmp</ImageUrl>
<NavigateUrl>http://msdn.microsoft.com</NavigateUrl>
<AlternateText>Support for developers</AlternateText>
<Impressions>40</Impressions>
<Keyword>Support</Keyword>
</Ad>
</Advertisements>
save this xml file as adverts.xml.
Add ad rotator control from tool box. click the control press f4 and in properties window in advertisement file option put adverts.xml
Add a new web page(add new item) adsforyou.aspx and add the following code after pressing f7 for code behind file(remember we are working on vb based asp.net)
in the adpath.txt file you will get the report of the clicks. You thus know when the banner is clicked!
Partial Class adsforyou
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object,_
ByVal e As System._
EventArgs) Handles Me.Load
Try
Dim strAdPath As String
'Get the URL to navigate to.
strAdPath = Request.QueryString(_
"Adpath")
'Log the ad click to a text file
(you can use a database).
Dim AdFile As New IO.FileInfo
(Server.MapPath("AdResponse.txt"))
Dim AdData As IO.StreamWriter
AdData = AdFile.AppendText
AdData.WriteLine(Now().ToString & ":
Ad clicked.
Redirect to " & _
strAdPath)
AdData.Close()
'Redirect the user to the ad URL.
Response.Redirect_
(strAdPath)
Catch ex As Exception
ex.Message.ToString()
End Try
End Sub
End Classit may not work until you do this:
add the following code to the main web page advertisehere.aspx after double clicking on the adrotator control dropped from toolbox on to the page
Partial Class advertisehere
Inherits System.Web.UI.Page
Protected Sub AdRotator1_AdCreated_
(ByVal sender As Object,_
ByVal e As System.Web.UI.WebControls._
AdCreatedEventArgs)_
Handles AdRotator1._
AdCreated
e.NavigateUrl = "adsforyou.aspx?Adpath=" _
& e.NavigateUrl
End Sub
End Class
'this will be advertisehere.aspx.vb- Creating a simple AJAX application
With AJAX asp.net offers more functionality to your webpage or website. I will here create a new Ajax enabled application.This application displays the current date and time, but there is no page flash. In...
- counting visits to your website
I assume you all know the concept of cookies in the web technology arena. I am going to show you how you can count the number of visits to your website. step 1: create a folder "Visits" in the wwwroot...
- Guide on double dimensional array
I want to show readers of my blog this interesting triangle formation which i worked out. This is usually asked in exams input 1 4 5 6 7 outout 1 4 5 6 7 5 9 11 13 14 20 24 34 44 ...
- The basics of exception handling
We usually do undergo a feature called try and catch.Whats the use of exception handling anyway? To put it like this whenever you are running a certain application or project chances are that you may make a...
- The object oriented way
Long codes , confusing tedious? try the object oriented way! Whats oops? Computer technology as science has undergone changes in years. Java Microsoft have evolved with new techniques to make computing easy...
- how to learn php
It become a tough question when it comes to learning php. W3shools.com has solved the problem to some extent. I felt like sharing more to make it easy. First of all download easy php heredownload php now...
- letters written by Indira Gandhi to her friend Dorothy Norman
By Dorothy Norman This is to illuminate and reveal the private individual behind the public image of my dearest Indira Gandhi. It is in no sense a biography or a political document. These letters were not...







fatma78 7 months ago
Good article
I have found good website for Microsoft.Net professional www.dotnettechy.com here we can search articles, Problem and solutions and interview questions and answer.
We can also bookmark for further reference.
Also we can submit and manage .net articles URLs, problems, and interview questions.
www.dotnettechy.com