How do I add a JavaScript script or library to the end of a asp.net page before the end tag of the page? Several methods are summarized as reference 
1 A better reference to the JavaScript library (jsfile.js) using registerclientscriptinclude: 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
if (! Page.ClientScript.IsClientScriptIncludeRegistered ("Jsfileinclude")) 
  
Page.ClientScript.RegisterClientScriptInclude ("Jsfileinclude", "jsfile.js"); 
  
 
 
 
  
Add a JavaScript library reference at the beginning of the document ViewState data. 
2 to insert some JavaScript code into the page, you can use the RegisterStartupScript method: 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
String jscodeblock = "var mystr= ' here"; alert (mystr); "; 
  
if (! Page.ClientScript.IsStartupScriptRegistered ("Myjscode")) 
  
Page.ClientScript.RegisterStartupScript (typeof (String), "Myjscode", Jscodeblock, True); 
  
 
 
 
  
The Javascript code is added to the end of the document. 
When the last parameter is set to the true,.net frame, it is automatically added to the start and end of the script tag (or merge with the other generated JavaScript code, based on the same script tag). 
But we can also use the RegisterStartupScript method to load a reference to the JavaScript library at the end of the document, we write the complete JS file, and set the last argument to false: 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
String jsfile = "<script src=\" jsfile.js\ "type=\" text/javascript\ "></script>"; 
  
if (! Page.ClientScript.IsStartupScriptRegistered ("Myjsfileref")) 
  
Page.ClientScript.RegisterStartupScript (typeof (String), "Myjsfileref", Jsfile, false);