Best Practices, How To Specify Relative Path For Css,javascript And Images Files?
Solution 1:
Keep in mind when considering these answers that "root-relative" and "root of the site" may really mean the root of the path following the domain name in the url. You may need to take into account scenarios where your web site is not located at the root. In such scenarios, root-relative paths would potentially point to a different web site.
In ASP.NET you can use a leading ~ to generate urls relative to the root of current site for most server-side controls, as in:
<img src="~/image.jpg" runat="server">
You can also use the ResolveUrl method (and other similar methods) to expand such paths without using server-side controls.
Solution 2:
Use a root-relative path like this:
/js/javascriptfile.js
/css/style.css
the first / means at the root of the site.
Solution 3:
Use absolute or root-relative paths to avoid confusion in multi-level pages.
Look here for more information: http://www.motive.co.nz/glossary/linking.php
Post a Comment for "Best Practices, How To Specify Relative Path For Css,javascript And Images Files?"