JS code added from codebehind doesn't run
<p>I wrote an application in ASP.Net I have a problem with centering a dynamically created popup. In the popup control I inserted the following code: </p>

<pre><code>string script = "&lt;script type='text/javascript'&gt;";
script += "$(document).ready(setMargin();); ";
script += "function setMargin(){ ";
script += "var wid = $('MC_resultPopup_pnlResultPopup').width();";
script += "$('MC_resultPopup_pnlResultPopup').css('margin-left', wid/2 + 'px');}";
script += "&lt;/script&gt;";

Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "SetAutoWidth", script);
</code></pre>

<p>But this code is not working. It does not even start. What am I doing wrong?</p>
