Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Talk to Webmaster Tony John
Online Members
naveensanagasetti
prasad
abhinav
Ramu
Ultimaterengan
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
Member Rank:
0
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
Tweet
Responses
#62425 Author:
Tony John
Member Level:
Gold
Member Rank:
68
Date: 09/Jul/2006 Rating:
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
#317665 Author:
lavanya
Member Level:
Gold
Member Rank:
0
Date: 17/Nov/2008 Rating:
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
#322795 Author:
ChandraShekar Thota
Member Level:
Gold
Member Rank:
35
Date: 28/Nov/2008 Rating:
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
Free Online,Offline Sessions
www.hyderabadtechies.info
chandrashekarthota@gmail.com /92 93 95 95 39
FREE SESSIONS ON .NET AND VISUALSTUDIO
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
.
Tweet
Next :
Validation Controls
Previous :
Please Please help.................. tooo urgent
Return to Discussion Forum
Post New Message
Category:
Active Members
Today
Anil Kumar ...
(34)
Padma
(26)
aniethacosmic
(14)
Last 7 Days
baskar
(326)
Ultimaterengan
(169)
Asheej T K
(161)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds