Default.aspx 1.5 KB

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