web 2.0


Adding Adsense Search to an ASPX webpage

When I first put this blog up I found that putting Google’s Adsense for Search a real head-scratcher. 

If you are reading this, you know that Google AdSense for Search does not work on an aspx page. The problem is that an aspx page can only have one form tag placed on it… this is when the head scratching starts.

After spending a few fruitless hours trying some crazy ideas in DreamWeaver, I opened an HTM file which was linked to my now-defunct FrontPage application. Lo and behold that this triggered the idea to use an iframe to place the page containing the code. This works in a similar way as the “include virtual/file” instruction in classic ASP. 

So, here are the steps to carry that out: 

1.    Create an HTM page and remove all the html code in it. Paste the Google AdSense for Search code into this page;
2.    Save the htm page as “googlesearch.htm”;
3.    Open your aspx MasterPage and locate the area where the search box will be placed;
4.    Paste the code below in this location 

<iframe src=" googlesearch.htm" mce_src=" googlesearch.htm" width="100%" height="50pc" frameborder="0" scrolling="no"></iframe>

I set the width 100% so that I cover the width of my blog’s MasterPage. I set the height as 50pc so that the iframe does not take too much space; otherwise, you are left with lots of blank on the page. 

Another important point is to set the scrolling attribute to “no”. Finally, save both pages (the htm and aspx MasterPage). Place the MasterPage back into its folder and place the HTM page on your web root (or wherever it is relative to the document that will load it). You are now a happy with you Google Adsense for Search on an aspx page!

Tags: , ,

ASP.NET

Comments

Comments are closed