R – ASP.NET master pages order of adding scripts

asp.netclientscriptmanagermaster-pages

I have a master page that adds the jquery library via a registerclientscriptinclude:

Page.ClientScript.RegisterClientScriptInclude(this.GetType(), 
    "JQuery", 
    Page.ResolveUrl("~/Scripts/jquery-1.2.6.min.js"));

In a page that uses that master page I want to include a script that depends on jquery:

Page.ClientScript.RegisterClientScriptInclude(this.GetType(), 
    "jqplugin1", 
    Page.ResolveUrl("~/Scripts/jquery.plugin1.compressed.js"));

This causes a problem because the page's client scripts are written first and then the master pages client scripts (causing the plugin to complain that "jquery" is undefined).

Is there anyway to control the ordering of client script includes? Alternatively any recommendation on how best to control this (temporarily the master page is just including everything… but that's not going to work long term).

Best Answer

since master page is like a control embedded in a page, you can add these scripts towards the end of the page cycle, the control would fire first and then page, so your page would be fine.