When developing a web project, you will always encounter many relationships between user controls. ascx and pages, or between pages and master pages. Use a partial page
It is better to dynamically introduce JS files or style sheet files to the master page, or dynamically introduce JS files and style sheets as needed in the user control.
Here is a method I introduced:
// Introduce the JS File
Htmlgenericcontrol scriptcontrol = new htmlgenericcontrol ("script ");
Scriptcontrol. Attributes. Add ("type", "text/JavaScript ");
Scriptcontrol. Attributes. Add ("language", "JavaScript ");
Scriptcontrol. Attributes. Add ("src", "http://images.dayoo.com/travel/9208.files/changeimg.js ");
Page. header. Controls. Add (scriptcontrol );
// Introduce the style sheet
Literal csscontrol = new literal ();
Csscontrol. Text = "<link href = \" http://images.dayoo.com/photo/17358.files/css.css\ "rel = \" stylesheet \ "type = \" text/CSS \ "/> ";
Page. header. Controls. Add (csscontrol );
the preceding Code is displayed in the page or control pageload.