Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a question, how do you link CSS to pages on Solution's subfolder

I know how to link CSS and its working on my pages

C#
<link rel="stylesheet" type="text/css" href="Stylesheet/Default.css" />


I also have other webpages inside folders forexample

I have a folder named adminpages and inside are adminpage1 and so on...
however, when I use the code above, It does not get the css properties..


how can I properly link it?
Posted
Comments
Anubhav689 26-Mar-14 0:44am    
If it was working on Webpages which are outside of any folder then it should work on those pages also which are inside of some folders or sub folders, it might be possible that your Browser is not updating the CSS, you should delete all the History and Cookies of your Browser and then should try again.

In visual studio, open your aspx page, then drag you css file from solution explorer and drop it onto the head section of your aspx page, it will automatively create the link for you.
 
Share this answer
 
v2
I am not clear with your directory structure. I am just giving a general description. If the file is on subfolder then you can use folder name as in your example. If it is outside then you need to use ".." to go to parent and then navigate back respective subfolder. But the best solution is to use "~" to specify the complete path. This will work even when the file is moved to different location with the website.
 
Share this answer
 
Comments
Ankur\m/ 26-Mar-14 0:48am    
Can you explain the second part of your answer about "~". How it can be used and how would it still work if the file is moved?
Let me tell you that you are wrong about it. Tilde will just help you get to the root directory. The path further needs to be defined and changed when the file location is changed.
ArunRajendra 26-Mar-14 1:04am    
Yes you are right what I mean is you moving the aspx or any content file. NOT the css file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900