Posted By

inreflection7 on 06/02/11


Tagged

javascript aspx


Versions (?)

< script > in ASPX


 / Published in: ASP
 

  1. When adding JavaScript files to an ASP.NET page, always use asp:ScriptManager.
  2.  
  3. Instead of this:
  4. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  5. <script type="text/javascript" src="~/App_Atom/ux/js/IframeOnClick.js"></script>
  6. <script type="text/javascript" src="~/App_Atom/ux/js/common.js"></script>
  7.  
  8. Do this:
  9. <asp:ScriptManager runat="server">
  10. <Scripts>
  11. <asp:ScriptReference Path="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" />
  12. <asp:ScriptReference Path="~/App_Atom/ux/js/IframeOnClick.js" />
  13. <asp:ScriptReference Path="~/App_Atom/ux/js/common.js" />
  14. </Scripts>
  15. </asp:ScriptManager>
  16.  
  17. btw asp:ScriptManager goes in the MasterPage. If it's a sub-page then use asp:ScriptManagerProxy.

Report this snippet  

You need to login to post a comment.