I have two javascript block in the page , one is adding dynamicllay which is , providing all images. should add above existing javascript on page
<p>i am using following code to add javascript dynamically </p>

<pre><code> HtmlGenericControl scriptTagLinks = new HtmlGenericControl("script");
 scriptTagLinks.Attributes["type"] = "text/javascript";
 var scrip = "var aImgs=[" + appendString.ToString().TrimEnd(new char[] { ',' }) + "]";
  scriptTagLinks.InnerHtml = scrip;
</code></pre>

<p>Javascript is adding to ascx page . But my problem I have two javascript block in the page , one is adding dynamicllay which is , providing all images. another one javascript as follows .</p>

<pre><code>&lt;script type="text/javascript&gt;
     window.onload = function () {
     for (var i = 0; i &lt; aImgs.length; i++) {
            var oImg = new Image();
            oImg.src = aImgs[i];
            aImages.push(oImg);

            oImg.onload = function () {
                textureWidth = oImg.width;
                textureHeight = oImg.height;
            }
        }} 
&lt;/script&gt;
</code></pre>

<p>but dynamically created javascript is being added below the script . But should add above the script like this .</p>

<pre><code>   &lt;script type="text/javascript"&gt;
        var aImgs = [
        'DesktopModules/DNAiusCubeImages/Check/pic1.jpg',
        'DesktopModules/DNAiusCubeImages/Check/pic2.jpg',];
    &lt;/script&gt;
&lt;script type="text/javascript&gt;
         window.onload = function () {
         for (var i = 0; i &lt; aImgs.length; i++) {
                var oImg = new Image();
                oImg.src = aImgs[i];
                aImages.push(oImg);

                oImg.onload = function () {
                    textureWidth = oImg.width;
                    textureHeight = oImg.height;
                }
            }} 
    &lt;/script&gt;How can i achieve this . 
</code></pre>
