Proper way to use JQuery when using MasterPages in ASP.NET?

前端 未结 4 1105
日久生厌
日久生厌 2020-11-30 00:46

I have no issues when doing using JQuery in a aspx page without a masterpage, but when I try to use it in pages that have a masterpage, it doesn\'t work, so I end up putting

4条回答
  •  长情又很酷
    2020-11-30 01:20

    This is what will work inside a Master page:

    For Script file:

    
    

    For CSS file:

    
    

    Additional Notes:

    1. Use the minified versions as could as possible (FileName.min.js) and (FileName.min.css) to reduce loading time and improve SEO.
    2. Put the CSS before the and the script before the to enhance performance and improve SEO.
    3. The tile character (~) in the path will resolve automatically to the root of your website.
    4. Do not forget to use runat="server" for the stylesheet only. The script must not have runat="server" because it already uses server operators <%= %>.
    5. You can use the online http://jscompress.com/ to compress your javascript and https://csscompressor.net/ to compress your CSS files.

提交回复
热议问题