C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

no of click on advertisement in asp.net application


Posted Date: 09 Jul 2006      Posted By: arif shareef      Member Level: Silver     Points: 2   Responses: 3



suppose i have asp.net appliaction in which i have some advertisement banner of various compnay ,so how to find number of user click on that banner and from which IP address it was clicked.ineed sample code for this




Responses

Author: Tony John    09 Jul 2006Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

You can have the advertisement link to your own page with some querystring indicating the type of Ad. In your page, record the count in database and then redirect to advertiser's page.

For example, you have an image Ad for Microsoft web site, you can have it like this:

<a href='http://www.mysite.com/RecordAdClicks.aspx?AdId=300'><img src='MicrosoftImage.gif'></a>

When somebody click on the image, it will redirect to the page RecordAdClicks.aspx. In that page, you increment the click count and save to database. Then redirect to the advertiser's page.

Regards,
Tony John
Webmaster - dotnetspider.com



Author: lavanya    17 Nov 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 6

hai..

source code:
------------
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/middle.jpg"
onclick="ImageButton1_Click" />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>


code behind:
--------------

XmlDocument doc = new XmlDocument();
int i;
DataSet ds;
int j;
protected void Page_Load(object sender, EventArgs e)
{

}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
//retrieve ip address
string host = System.Net.Dns.GetHostName();
string hostname = Dns.GetHostEntry(host).HostName;
IPHostEntry ipEntry = Dns.GetHostEntry(host);
IPAddress[] addr = ipEntry.AddressList;



//xml
doc.Load(Server.MapPath("~/count.xml"));
XmlNodeList list = doc.SelectNodes("//NewDataset/section");


foreach (XmlNode node in list)
{

//checking whether the ip address is there or not

if (addr[0].ToString() == node.ChildNodes[1].InnerText)
{
i = Convert.ToInt32(node.ChildNodes[0].InnerText);
i += 1;
node.ChildNodes[0].InnerText = i.ToString();
doc.Save(Server.MapPath("~/count.xml"));
j = 1;
}
else
{
j = 0;
}

}
if (j == 0)
{
ds = new DataSet();
ds.ReadXml(Server.MapPath("~/count.xml"));
DataRow row = ds.Tables[0].NewRow();
row["count"] = "1";
row["ip"] = addr[0].ToString();
ds.Tables[0].Rows.Add(row);
ds.WriteXml(Server.MapPath("~/count.xml"));
}
Response.Write(i);


}

create one count.xml file..

Regards
LAvanya



Author: ChandraShekar Thota    28 Nov 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 5

Hi Arif,

Do this

1. take a database and maintaina atble for clicks
2. capture ip address on click event with Dns.GetHostEntry(host).HostName
3. take a column in table as clicks and assign 0 initially
4. on click even of image write a code to increment table field by one
5. insert ip address on every click to that table.
6. retrieve table fields values when ever necessary.

Hope you understood

cheers
chandu

Chandra Shekar Thota
Microsoft MVP
DNS is Y(Our) Site.Please work more on it to make it Worlds Best Technical Site
chandrashekarthota@gmail.com



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Validation Controls
Previous : Please Please help.................. tooo urgent
Return to Discussion Forum
Post New Message
Category: ASP.NET



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use