Skip to content
Shannon Deminick edited this page Apr 27, 2015 · 4 revisions

Html tag attributes

In many cases you may want to add custom html attributes to the rendered script or link tags that are output. There are numerous overloads for registering your dependencies and many of them contain an HtmlAttributes property that you can set.

It's important to note that if your Require statements have different html attributes applied then CDF will output them as different html script/link tags because the attributes will be different. Similarly if the attributes are the same then CDF will bundle them together. CDF is smart enough to bundle the dependencies together that have matching attributes and will maintain the same output order in html.

Examples:

MVC

Html.RequiresCss("~/css/styles.css", new Dictionary<string, string>() { { "media", "print,projection" } });

Webforms

Webforms controls can be manipulated directly in the codebehind file by modifying the HtmlAttributes property, or can be done in markup with the HtmlAttributesAsString property with a comma separated list of items such as: key1:'value1',key2:'value2'

<CD:CssInclude runat="server" FilePath="~/css/styles.css" HtmlAttributesAsString="media:'print,projection'" />
Clone this wiki locally