Documentation > Services API > ServicesOutput > RenderCSSLink(Int32,String,String,String,OutputContext)

RenderCSSLink

For creating links to CSS assets. Accepts an asset Id and if loaded, renders a link to it as an HTML link elementt. Use as a convenience function when building wrapper templates and anywhere you need to load a css asset in output.

public System.String RenderCSSLink(Int32,String,String,String,OutputContext)


Returns

String containing HTML code for loading a CSS Asset.

Parameters

NameDescriptionType
cssAssetId The Asset ID of the CMS Asset that contains the CSS code. System.Int32
mediaType Optional mediatype. System.String
cssIdAttribute Optional html ID attribute for css link. System.String
qString Optional query string appended to css link. System.String
context Optional current OutputContext for checking the publishing status. CrownPeak.CMSAPI.OutputContext

Code Example

C#

Sample:

            Out.WriteLine(ServicesOutput.RenderCSSLink(cssAssetId, context: context));
            /*returns and outputs:
            <link rel="stylesheet" type="text/css" href="[[cssAsset publishing path or cms path]]?" */
            
            Asset cssFolder = Asset.Load(asset["css_Folder"]);
            Out.WriteLine( ServicesOutput.RenderCSSLink(cssFolder.ChildId, mediaType: "print", cssIdAttribute:"myCssIdAttribute", qString: "myQString",context) );
            /*returns and outputs:
            <link rel="stylesheet" type="text/css" href="[[cssAsset publishing path or cms path]]?myQString" media="print" id="myCssIdAttribute" />
            assuming both the css and the containing/wrapping assets are in publishing states.*/
            

Connect with Crownpeak