I'm guessing that your script was working before specifically because it was placed at the end of the document - and that it is not working now because the script manager is including it earlier in your document - and you're assuming some DOM elements will be there (EDIT: or the array you mention in the comments after you posted the initial question) - which aren't at the time the script is loaded.
I'm going to give an example using jQuery - but this is perfectly useful even if you aren't using jQuery... you'll just have to substitute the necessary bits for the non-jQ versions... but I think it will get the point across.
Right now you're probably doing something like this:
doSomething();
You need to do this:
$().ready(function() { doSomething(); });
This will cause your code to run only after the page has finished loading.
EDIT:
Non-Jq version of $().ready(); here: What is the non-jQuery equivalent of '$(document).ready()'?
EDIT Based on your comment "there is an array which is being generated that it uses, it needs to be loaded after... "
Can you put whatever is inside your script into a function, and just call the function after you generate the array? This would be fairly standard - instead of relying on some arbitrary page-load sequence which is - obviously - unpredictable and open to change.
EDIT: Since you've downvoted my answer, and, apparently, the question is nebulous - perhaps you're just confused as to how to use RegisterClientScriptInclude (which doesn't really seem to relate to your other problem regarding timing - it certainly won't magically solve any timing issues you have - and the fact that you're relying on script-load timing/sequencing at all seems to be a problem - but I'll put it in here anyways - because, just maybe, that's what you really wanted to know):
There are three functions you can use to register client scripts in ASP.NET:
- RegisterClientScriptInclude (the one you cite)
- RegisterClientScriptBlock
- RegisterStartupScript
http://msdn.microsoft.com/en-us/library/bb360649.aspx, http://msdn.microsoft.com/en-us/library/btf44dc9.aspx, and http://msdn.microsoft.com/en-us/library/asz8zsxy.aspx respectively.
The samples for RegisterClientScriptBlock are relatively straight-forward:
// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the client script is already registered.
if (!cs.IsClientScriptBlockRegistered(csType, csName))
{
StringBuilder csText = new StringBuilder();
csText.Append("<script type=\"text/javascript\"> function DoClick() {");
csText.Append("Form1.Message.value='Text from client script.'} </");
csText.Append("script>");
cs.RegisterClientScriptBlock(csType, csName, csText.ToString());
}
It doesn't get too much easier than that... cut and paste. Replace with your js reference.
There are tutorials online:
http://www.codeproject.com/KB/aspnet/Mayank_Gupta.aspx
Based on your comment that you used to put the script at the bottom of the page, you should probably be using "RegisterStartupScript" not "RegisterClientScriptInclude" if you want results which are more similar to what you had previously.