C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




no of click on advertisement in asp.net application


Posted Date: 09 Jul 2006      Total Responses: 3

Posted By: arif shareef       Member Level: Silver     Points: 2


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: GoldRating:     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.


Author: lavanya    17 Nov 2008Member Level: GoldRating:     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:     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



Post Reply
You must Sign In to post a response.
Next : Validation Controls
Previous : Please Please help.................. tooo urgent
Return to Discussion Forum
Post New Message
Category: ASP.NET



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween mask

Contact Us    Privacy Policy    Terms Of Use