Question

I have created css file called stylesheet1.css in folder called Mystyles. See image below

I want to refer css file in my visual studio in one of my .aspx page, so i wrote something like this but its not using this stylesheet

<link href="~sitecollection/_catalogs/masterpage/MyStyles/Stylesheet1.css"  />

Please can someone tell how can i refer this? Also could be nice if there are any articles which i can read about to get idea about referring images and css files in sharepoint in different ways.

enter image description here

Était-ce utile?

La solution

A correct way to reference a CSS from your master page is:

 <SharePoint:CssRegistration Name="&lt;% $SPUrl:~sitecollection/_catalogs/masterpage/MyStyles/Stylesheet1.css %&gt;" runat="server" After="corev15" />

Yup, surprising, but fully functionnal on my side! This is the only way to set a dynamic reference to a CSS...

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top