| Author: Tony John 09 Jul 2006 | Member Level: Gold | 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.
|
| Author: lavanya 17 Nov 2008 | Member Level: Gold | 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
|
| Author: ChandraShekar Thota 28 Nov 2008 | Member Level: Diamond | 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
|