This is a migrated thread and some comments may be shown as answers.
StylesheetRegister Conditional Comments
2 Answers 29 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Karl
Top achievements
Rank 1
Karl asked on 03 Dec 2009, 12:41 PM
Hi,

Is it possible to wrap conditional comments around certain stylesheets?

e.g.
<!--[if IE 6]>  <link rel="stylesheet" type="text/css" href="/Content/css/main-ie6.css" /><![endif]-->

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 03 Dec 2009, 12:43 PM
Hello Karl,

Unfortunately we don't support conditional comments for the time being. However this sounds like a very nice feature and I have logged it in our TODO list.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Karl
Top achievements
Rank 1
answered on 03 Dec 2009, 02:31 PM
Thanks Atanas,

In case anyone else needs this functionality, here's how we implemented this using the following syntax:
Html.Telerik().StyleSheetRegistrar() 
                     .DefaultGroup(group => group.Add("Site-ie6.css"
                                                 .Add("Page-ie6.css"
                                                 .Combined(true
                                                 .ConditionalComment("if IE 6"
                                  ) 

We extended IWebAssetItemMerger with a new method MergeWithConditionalComments which returns a dictionary<string,string> containing the stylesheet and conditional commment.

Finally, updated StyleSheetRegistrar with:
            if (!mergedList.IsEmpty()) 
            { 
                foreach (KeyValuePair<string,string> keyValue in mergedList) 
                { 
                    if (!String.IsNullOrEmpty(keyValue.Value)) 
                    { 
                        writer.WriteLine("<!--[" + keyValue.Value + "]>"); 
                    } 
                    writer.WriteLine("<link type=\"text/css\" href=\"{0}\" rel=\"stylesheet\"/>".FormatWith(keyValue.Key)); 
                    if (!String.IsNullOrEmpty(keyValue.Value)) 
                    { 
                        writer.WriteLine("<![endif]-->"); 
                    } 
                     
                } 
            } 


Tags
General Discussions
Asked by
Karl
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Karl
Top achievements
Rank 1
Share this question
or