Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP.NET (http://www.go4expert.com/forums/asp-net/)
-   -   Adrotator - an Advertisement File using ASP.NET (http://www.go4expert.com/forums/adrotator-advertisement-file-using-t20699/)

sameer_havakajoka 19Jan2010 11:43

Adrotator - an Advertisement File using ASP.NET
 

Introduction



I am trying to re-solve the Hit-Counts with the help of an Ad-Rotator used as an Advertisement file using ASP.NET.

Background



The AdRotator control is used to display a sequence of ad images, which when clicked on gives the Hit-Count of the Navigation URL.

The code



Code: ASP.NET

In AdRedirector.aspx.cs

Code:

protected void Page_Load(object sender, EventArgs e)
{
        String adName = string.Empty;
        String redirect = string.Empty;
        if (adName == null | redirect == null)
        {
                redirect = "Default.aspx";
        }
        adName = Request.QueryString["ad"];
        redirect = Request.QueryString["target"];
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        String docPath = @"~/App_Data/AdResponses.xml";
        doc.Load(Server.MapPath(docPath));
        System.Xml.XmlElement root = doc.DocumentElement;
        System.Xml.XmlNode adNode =root.SelectSingleNode(@"descendant::ad[@adname='" + adName + "']");
        if (adNode != null)
        {
                int ctr =
                int.Parse(adNode.Attributes["hitCount"].Value);
                ctr += 1;
                System.Xml.XmlNode newAdNode = adNode.CloneNode(false);
                newAdNode.Attributes["hitCount"].Value = ctr.ToString();
                root.ReplaceChild(newAdNode, adNode);
                doc.Save(Server.MapPath(docPath));
        }
        Response.Redirect(redirect);
}

In AdRedirector.aspx,
Code:

<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/Sample.ads">
</asp:XmlDataSource>
</div>
</form>


shabbir 20Jan2010 10:09

Re: Adrotator - an Advertisement File using ASP.NET
 
Finally moved into forum.

I guess you need to work on your code a bit harder.

Can you please explain the following lines
Code:

        String adName = string.Empty;
        String redirect = string.Empty;
        if (adName == null | redirect == null)
        {
                redirect = "Default.aspx";
        }


seangtz 3Feb2010 10:04

Re: Adrotator - an Advertisement File using ASP.NET
 
Some of the code lines seems different .....

sameer_havakajoka 3Feb2010 10:51

Re: Adrotator - an Advertisement File using ASP.NET
 
differenet???

dasli 9Jun2010 16:16

Re: Adrotator - an Advertisement File using ASP.NET
 
mmm...useful for me, thanks for info...


All times are GMT +5.5. The time now is 03:22.