js works inside the page but not in code behind
<p>I have this function put in a MasterPage, which shows up an mp3 player:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function() {
        var stageW = 500;
        var stageH = 216;
        var cacheBuster = Date.parse(new Date());

        var flashvars = {};
        var params = {};

        params.bgcolor = '#F6F6F6';
        params.allowfullscreen = 'true';


        flashvars.stageW = stageW;
        flashvars.stageH = stageH;

        flashvars.pathToFiles = '';

        flashvars.settingsPath = '../mp3player/mp3player_settings.xml';
        flashvars.xmlPath = '&lt;%# getRestXmlPlayerUrl() %&gt;';

        flashvars.keepSelected = 't';
        flashvars.selectedWindow = '4';
        flashvars.slideshow = 't';

        flashvars.imageWidth = '130';
        flashvars.imageHeight = '130';

        swfobject.embedSWF('swf/preview.swf?t=' + cacheBuster, 'myContent', stageW, stageH, '9.0.124', 'swf/expressInstall.swf', flashvars, params);
    }); 
    &lt;/script&gt;
</code></pre>

<p>All works great.
But, because i have some ajax on the page with update panel, the flash in not rendered when ajax requests occurs so i need to register this function and i've tried something like this:</p>

<pre><code>protected void Page_PreRender(object sender, EventArgs e)
    {
    Type cstype = this.GetType();
    String csnameForPlayer = "applyStyleToMp3Player";
        if (!Page.ClientScript.IsClientScriptBlockRegistered(cstype, csnameForPlayer))
        {
            StringBuilder cstextForPlayer = new StringBuilder();
            cstextForPlayer.Append(" $(document).ready(function() { "
    + " var stageW = 500;"
    + " var stageH = 216;"
    + " var cacheBuster = Date.parse(new Date());"

    + " var flashvars = {};"
    + " var params = {};"

    + " params.bgcolor = '#F6F6F6';"
    + " params.allowfullscreen = 'true';"


    + " flashvars.stageW = stageW;"
    + " flashvars.stageH = stageH;"

    + " flashvars.pathToFiles = '';"

    + " flashvars.settingsPath = '../mp3player/mp3player_settings.xml';"
    + " flashvars.xmlPath = '&lt;%# getRestXmlPlayerUrl() %&gt;';"

    + " flashvars.keepSelected = 't';"
    + " flashvars.selectedWindow = '4';"
    + " flashvars.slideshow = 't';"

    + " flashvars.imageWidth = '130';"
    + " flashvars.imageHeight = '130';"

   + " swfobject.embedSWF('swf/preview.swf?t=' + cacheBuster, 'myContent', stageW, stageH, '9.0.124', 'swf/expressInstall.swf', flashvars, params);"
   + "});   ");
        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), csnameForPlayer, cstextForPlayer.ToString(), true);
    }
}
</code></pre>

<p>Well, this does not work. The flash player does not appear any more, so, i assume that is something wrong in the cstextForPlayer.</p>

<p>I've spent over one hour to figure it out but i've failed.</p>

<p>Does anyone see the problem?</p>

<p>Thanks in advance.</p>
