Adrotator - an Advertisement File using ASP.NET

Discussion in 'ASP.NET' started by sameer_havakajoka, Jan 19, 2010.

  1. sameer_havakajoka

    sameer_havakajoka New Member

    Joined:
    Sep 14, 2009
    Messages:
    271
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Sleeping
    Location:
    Hava Ke Paro Me

    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>
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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"; 
    	}
    
     
  3. seangtz

    seangtz New Member

    Joined:
    Jun 6, 2008
    Messages:
    126
    Likes Received:
    3
    Trophy Points:
    0
    Some of the code lines seems different .....
     
  4. sameer_havakajoka

    sameer_havakajoka New Member

    Joined:
    Sep 14, 2009
    Messages:
    271
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Sleeping
    Location:
    Hava Ke Paro Me
  5. dasli

    dasli New Member

    Joined:
    Aug 13, 2009
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    mmm...useful for me, thanks for info...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice