Resource registration before class namespace
Copy codeThe Code is as follows:
[Assembly: System. Web. UI. WebResource ("XXX. js. FilePlugin. js", "text/javascript")]
OnPreRender event
// Resource Name
String _ strResourceKey = ""; // Resource Name
ClientScriptManager _ csm = Page. ClientScript;
// If (this. Page. Header. FindControl (_ strResourceKey) = null)
//{
// String _ src = _ csm. GetWebResourceUrl (this. GetType (), _ strResourceKey );
// Literal _ literal = new Literal ();
// _ Literal. ID = _ strResourceKey;
// _ Literal. text = string. format ("\ n <script type = \" text/javascript \ "src = \" {0 }\ "> </script>", _ src );
// This. Parent. Page. Header. Controls. Add (_ literal );
//}
// If (! This. Page. ClientScript. IsStartupScriptRegistered (_ strResourceKey ))
//{
// String _ src = _ csm. GetWebResourceUrl (this. GetType (), _ strResourceKey );
// _ Src = string. format ("\ n <script type = \" text/javascript \ "src = \" {0 }\ "> </script>", _ src );
// Page. ClientScript. RegisterStartupScript (this. GetType (), _ strResourceKey, _ src );
//}
If (! This. Page. ClientScript. IsClientScriptIncludeRegistered (_ strResourceKey ))
{
String _ src = _ csm. GetWebResourceUrl (this. GetType (), _ strResourceKey );
Page. ClientScript. RegisterClientScriptInclude (this. GetType (), _ strResourceKey, _ src );
}