SharePoint if statements for registering css
-
10-12-2019 - |
Question
In regular old HTMl we are allowed to do the following to use a css file depending on browser versions:
<link rel="stylesheet" href="path-to-styles/css/cssfilename.css">
<!--[if IE 7]>
<link rel="stylesheet" href="path-to-styles/css/cssfilename.css">
<![endif]-->
in a sharepoint user control we can add the files like so:
<SharePoint:CssRegistration name="/_layouts/solutionfolder/filename.css" After="corev4.css" runat="server"/>
How can I determine which version of the style sheet to load based on browser version? Or do I register them all then later determine which to use
Solution
You can use ConditionalExpression property to specify your conditional browser version.
For ex.
<SharePoint:CSSRegistration name="/_layouts/solutionfolder/filename.css" After="corev4.css" ConditionalExpression="lt IE 7" runat="server" />
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange