Render control results in javascript error
===

I have a usercontrol with some charts from Google chart api.

When the usercontrol is getting loaded and rendered by the server the usual way everything works as expected. But when I use a ajax webservice the render the control async and return the html with ajax and add it to the page, I get some script error in firebug(chrome calls it a ReferenceError): 

> "google is not defined"

![IMAGE][1]


My project is ASP.Net MVP Webforms with some javascript.

Control renderer code:

    public virtual string RenderControlToString(string path, bool htmlEncode)
    {
    	StringWriter stringWriter = new StringWriter();
    	this.RenderControl(path, (TextWriter)stringWriter);
    	string s = stringWriter.ToString();
    	if (!htmlEncode)
    		return s;
    	else
    		return HttpContext.Current.Server.HtmlEncode(s);
    }
    
    public virtual void RenderControl(string path, TextWriter writer)
    {
    	var page = new PageForRendering();
    	page.Controls.Add(page.LoadControl(path));
    	HttpContext.Current.Server.Execute((IHttpHandler)page, writer, true);
    }


(To omit the "need to be in form" error - there is a form on the page the control is added to)

    public class PageForRendering : Page
    {
    	public override void VerifyRenderingInServerForm(Control control)
    	{}
    }



Script on the usercontrol:

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
    	console.log("Loading Google Charts...");
    	google.load('visualization', '1.0', { 'packages': ['corechart'] });
    	console.log("Google Charts loaded!");
    
    	google.setOnLoadCallback(function () {
    		...some code...
    	});
    </script>

With firebug I found out that https://www.google.com/jsapi is loaded fine and only the first one of my console logs is printed.

I think it might be some kind of scope issue...

Hope you can help me because I have been blocked here for a while..


  [1]: http://i.stack.imgur.com/QmZiC.png