JavaScript and CSS referencing in master pages with authorization
i am developing in asp.net and i use different JavaScript and CSS files.
- i have a maste开发者_如何学编程r page "masterpage1"
- a folder admin
- in this folder i have a masterpage, called masterpageadmin which inherits from the masterpage1
- and all aspx files in the folder admin inherits from the masterpageadmin
- only the "admin" role can acess to the masterpageadmin and aspx files in the folder admin
My question: how should i reference in my masterpage1 my JavaScript and CSS, so that the aspx files in the admin folder can use them.
Cheers
ASP.NET doesn't bother to protect any non-ASP.NET files. This includes CSS, JS, HTML, JPG, PNG, ...
In otherwords, one doesn't worry about protecting CSS and JS.
When referencing a CSS or JS file in a mater page, It is usually necessary to use absolute paths instead of relative file path.
For example:
<link href="css/mystyles.css" rel="stylesheet" type="text/css" />
Is a relative path, the users browser will look for a folder called "css" in whatever directory the ASPX file is located in.
<link href="/css/mystyles.css" rel="stylesheet" type="text/css" />
Is an absolute path, the users browser will always look for a folder called "css" in the root of the web site, which may be different than the root of the web application.
Here is a great discussion on paths in ASP.Net http://www.west-wind.com/weblog/posts/132081.aspx
精彩评论