views:

13

answers:

1

I have about 50 sites that currently use a template code base to run. There are 3 master pages in the site and when we built them we didn't think to put a literal control on the page to plug in the site's google analytics code. Now I have to add the analytics code right before the closing body tag of the page and if I add a literal to the master page and push it to the web sites it will overwrite all the customizing that we've done on those sites. So, rather than changing the master page.aspx, I'd like to just write it to the page from the code behind if possible, but I can't figure out how. I've seen using the ClientScript to register javascript on the page, but is there a way to programmatically insert a literal as the last control on the page and set it's content to the analytics code? Thanks.

A: 

You can use the HtmlGenericControl:

http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlgenericcontrol(v=VS.80).aspx

Use the InnerHtml property to inject your HTML.

onof
I figured it out. I had to step through the control tree to figure out where the body ended and then use the AddAt method.
geoff swartz