4

Is it possible to set the media attribute on a link tag using the Telerik MVC Extensions StyleSheetRegistrar method?

<%= Html.Telerik().StyleSheetRegistrar()
    .DefaultGroup(group => group
        .Add("telerik.common.css")
        .Add("telerik." + ConfigurationManager.AppSettings["Telerik Theme"].ToLower() + ".min.css"))
%>

I want to add media="screen,handheld" to all the stylesheet links created by the above.

Antony Scott
  • 21,690
  • 12
  • 62
  • 94

2 Answers2

3

Nope, this is not currently possible. You can either modify the source code or use vanilla <link /> tags to register the CSS files. You don't seem to be using compression or combination so using <link /> tags seems feasible.

Atanas Korchev
  • 30,562
  • 8
  • 59
  • 93
  • thanks for the speedy response. is support planned for this in the near future? – Antony Scott Jul 22 '10 at 12:28
  • I am not really sure. It is not clear where the media should be specify - at group level or at asset level. If at group level - the implementation is trivial. If at asset level - we have to make sure we handle compression and combination properly as then we output only one tag. – Atanas Korchev Jul 22 '10 at 12:30
  • 4
    i think group level, then you just have one combined stylesheet for each type of media – Antony Scott Jul 22 '10 at 12:37
2

It actually is possible using a Replace:

@Html.Raw(Html.Telerik().StyleSheetRegistrar()
                      .DefaultGroup(group => group
                      .Add("default.css")
                      .Combined(true).Compress(true))
                      .ToHtmlString().Replace(">", " media=\"all\">"))
Markus
  • 21
  • 1