Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String adName   = Request.QueryString["ad"];
            String redirect = Request.QueryString["target"];

            if (adName == null | redirect == null)
            {
                redirect = "TestAds.aspx";
            }

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            String docPath             = @"~/App_Data/AdResponses.xml";

            doc.Load(Server.MapPath(docPath));
            System.Xml.XmlNode 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);
            }
            Response.Redirect(redirect);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String adversitmentName = Request.QueryString["ad"];
            String redirectAspx     = Request.QueryString["target"];

            if (adversitmentName == null | redirectAspx == null)
            {
                redirectAspx = "ShoppingPage_WebForm.aspx";
            }
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            String path = @"~/App_Data/AdResponses1.xml";

            doc.Load(Server.MapPath(path));
            System.Xml.XmlNode root   = doc.DocumentElement;
            System.Xml.XmlNode adNode = root.SelectSingleNode(@"descendant::ad[@adname='" + adversitmentName + "']");
            if (adNode != null)
            {
                int count = int.Parse(adNode.Attributes["hitCount"].Value);
                count += 1;
                System.Xml.XmlNode newAdNode = adNode.CloneNode(false);
                newAdNode.Attributes["hitCount"].Value = count.ToString();
                root.ReplaceChild(newAdNode, adNode);
                doc.Save(Server.MapPath(path));
            }
            Response.Redirect(redirectAspx);
        }