DynamicScriptReferences2.aspx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3. <script runat="server">
  4. protected void Page_Load(object sender, EventArgs e)
  5. {
  6. // If there is a ScriptManager on the page, use it.
  7. // If not, throw an exception.
  8. ScriptManager Smgr = ScriptManager.GetCurrent(Page);
  9. if (Smgr == null) throw new Exception("ScriptManager not found.");
  10. ScriptReference SRef = new ScriptReference();
  11. SRef.Assembly = "SystemWebExtensionsAUT";
  12. // If you know that Smgr.ScriptPath is correct...
  13. SRef.Name = "SystemWebExtensionsAUT.DynamicScriptReferencesHowTo.Scripts.Scripts.js";
  14. //Or, to set the ScriptMode just for the one script...
  15. SRef.ScriptMode = ScriptMode.Debug;
  16. Smgr.Scripts.Add(SRef);
  17. }
  18. </script>
  19. <html xmlns="http://www.w3.org/1999/xhtml">
  20. <head runat="server">
  21. <title>Dynamic Script References</title>
  22. </head>
  23. <body>
  24. <form id="form1" runat="server">
  25. <asp:scriptmanager ID="ScriptManager1" runat="server" />
  26. <div>
  27. </div>
  28. </form>
  29. </body>
  30. </html>