how to refer css file path
-
02-10-2020 - |
Pergunta
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.
Solução
A correct way to reference a CSS from your master page is:
<SharePoint:CssRegistration Name="<% $SPUrl:~sitecollection/_catalogs/masterpage/MyStyles/Stylesheet1.css %>" 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...
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange