How to programatically create a link to a script whcih shoudl return an image like google ads?

Last post 02-24-2007 12:25 AM by abrahamdurairaj. 5 replies.

Sort Posts:

  • How to programatically create a link to a script whcih shoudl return an image like google ads?

    02-12-2007, 11:07 AM
    • Loading...
    • tomyseb
    • Joined on 11-27-2006, 9:26 AM
    • Posts 147

    Hi all,

    I want to create an Ad Rotation just like that of Google.

    When I call a script, it shoud return an image.

    For example, when "ReturnProperAd.aspx" is called from the imageURL on a page, the script will process and return a particular JPEG file from a folder.

    How is it accomplished in C#.NET

    Thanking you in advance,

    Tomy

  • Re: How to programatically create a link to a script whcih shoudl return an image like google ads?

    02-12-2007, 11:47 AM

    Tomy,

     It would be a simple stuff that you would need to create. Here goes your quick snippet.

    1    using System;
    2    using System.Collections.Generic;
    3    using System.Text;
    4    
    5    class Class1
    6    {
    7        void RenderGoogleLikeAds()
    8        {
    9            StringBuilder _jsads = new StringBuilder();
    10   
    11           _jsads.Append("<script language=\"\">");
    12           _jsads.Append(RandomContent());
    13           _jsads.Append("</script>");
    14   
    15           System.Web.HttpContext.Current.Response.Write(_jsads.ToString());
    16   
    17       }
    18   
    19       string RandomContent()
    20       {
    21           // Your Random Logic Here ...
    22       }
    23   }
    24   
    
     

    You can create HttpHandlers also to do this job which would need much more code than your  ReturnProperAd.aspx

    Hope this helps

     

  • Re: How to programatically create a link to a script whcih shoudl return an image like google ads?

    02-13-2007, 11:39 PM
    • Loading...
    • tomyseb
    • Joined on 11-27-2006, 9:26 AM
    • Posts 147

    Abrahamdurairaj ,

    The method is really excellent.

    Thanks a lot for the same.

    Tomy

  • Re: How to programatically create a link to a script whcih shoudl return an image like google ads?

    02-13-2007, 11:41 PM
    • Loading...
    • tomyseb
    • Joined on 11-27-2006, 9:26 AM
    • Posts 147

    Abrahamdurairaj ,

    The method is really excellent.

    Thanks a lot for the same.

    But what does the following lines mean?

     

    StringBuilder _jsads =

    new StringBuilder();

     

    _jsads.Append("<script language=\"\">");

    _jsads.Append(RandomContent());

    _jsads.Append("</script>");

    Tomy

  • Re: How to programatically create a link to a script whcih shoudl return an image like google ads?

    02-22-2007, 12:43 AM
    • Loading...
    • tomyseb
    • Joined on 11-27-2006, 9:26 AM
    • Posts 147

    Thank you for your reply.

    Could you please tell me how to implement it into my webpage, say if I return "images/ads/ad1.jpg" from the function RandomContent()

     string RandomContent()
           {
               return "images/ads/ad1.jpg";

           }
    How can this image be dipslayed at the particular location of my web page with this function?

    Thanks

    Tomy

     

  • Re: How to programatically create a link to a script whcih shoudl return an image like google ads?

    02-24-2007, 12:25 AM

    Tomy I could reply immediately ...I was lil busy.. 

    Tomy you can do that .. and remember that you have have in mind that you are anytime not going to just display html content but you are going to render javascript content.  So it has to be like document.write stuff in javascript or you can assign some value to <img> tags or <div> tags.  hope this helps.  if you need more help pls. let me know

     

Page 1 of 1 (6 items)
Microsoft Communities
Page view counter