This is a migrated thread and some comments may be shown as answers.

StyleSheetManager with StyleSheetReferences as Hyperlinks (stylesheets not w/in project root)

3 Answers 121 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Karrie
Top achievements
Rank 1
Karrie asked on 13 Feb 2013, 09:21 PM


Greetings, 

Does RadStyleSheetManager already provide a way to include stylesheets external to the root directory of an application that I have not found?

For example, is there a way to set each of the RadStyleSheetManager.StyleSheets as hyperlinks in the code behind?

If not, why not ?  & is this a planned enhancement ? 

Take the following two examples : 

 Example1: Relative-to-root path fail. 
 Complies fine, but will error at runtime with "cannot use a leading .. to exit above the top directory" (.net constraint, not bug nor Telerik constraint).

<telerik:RadStyleSheetManager ID="RadStyleSheetManager" runat="server" OutputCompression="AutoDetect" EnableStyleSheetCombine="true">
       <StyleSheets>
           <telerik:StyleSheetReference Path="~/../../../WebAssets/Styles/mainstyles.css"/>
           <telerik:StyleSheetReference Path="~/../../../WebAssets/Styles/extrastyles.css"/>
       </StyleSheets>
</telerik:RadStyleSheetManager>

<appSettings>
   <add key="Telerik.Web.UI.StyleSheetFolders" value="~/../../../WebAssets/Styles"/>
</appSettings>


Example2:  virtual directory fail. 
.AXD can't serve the resources at all becuase it can't find them even though these paths are correct at runtime if linked 'normally'.
<telerik:RadStyleSheetManager ID="RadStyleSheetManager" runat="server" OutputCompression="AutoDetect" EnableStyleSheetCombine="true">
       <StyleSheets>
           <telerik:StyleSheetReference Path="~/VirtualDirWebAssets/Styles/mainstyles.css"/>
           <telerik:StyleSheetReference Path="~/VirtualDirWebAssets/Styles/extrastyles.css"/>
       </StyleSheets>
</telerik:RadStyleSheetManager>

<appSettings>
   <add key="Telerik.Web.UI.StyleSheetFolders" value="~/VirtualDirWebAssets/Styles"/>
</appSettings>


3 Answers, 1 is accepted

Sort by
0
Ivan Zhekov
Telerik team
answered on 20 Feb 2013, 11:59 AM
Hello, Karrie.

You can work with the Stylesheets collection from code behind:

var stylesheetRef = new Telerik.Web.UI.StyleSheetReference();
stylesheetRef.Path = "~/skins/Classic/ComboBox.Classic.css";
ssm.StyleSheets.Clear();
ssm.StyleSheets.Add(stylesheetRef);
 
// Note that I am loading a file from the virtual ~/skins folder
// Whereas ssm is the ID of the stylesheet manager on the page

On the second question -- I did not have any issues what so ever creating a virtual application and linking items from that location.

Web.config:
<add key="Telerik.Web.UI.StyleSheetFolder" value="~/skins/"/>

StyleSheetManager declaration:
<telerik:RadStyleSheetManager ID="ssm" runat="server">
    <StyleSheets>
        <telerik:StyleSheetReference Path="~/skins/Classic/ComboBox.Classic.css" />
    </StyleSheets>
</telerik:RadStyleSheetManager>

Perhaps you need to specify only the root of the virtual folder and not the entire path within it.

Greetings,
Ivan Zhekov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Karrie
Top achievements
Rank 1
answered on 05 Mar 2013, 08:37 PM


Greetings Ivan, 

My first question was misunderstood. 

The question is not about how to work with the StyleSheets collection. The question is asking how to include stylesheets external to (& above) the root directory of an application (whehter from code behind or in markup is irrelavant).


The second question/example, I believe, was also misunderstood. 

Reference to 'virtual directory' should have been clarified on my end instead as any of the following :  a virtual directory on the web server containing CSS files, an asset on a CDN, or just any css asset hosted on another server.   (ex : http://cdn.example.com/css/style.css)

In your example, '/skins' is still a child of the application root.  My question is focused towards a different case where the stylesheets are external to the root directory of a given application.

Normally, if one was writing a plain old HTML document, linking a stylesheet with a location of this nature is very easy. Something like ...

<link href="/WebAssets/Styles/extrastyles.css" rel="stylesheet" type="text/css" />

OR 

<link href="http://cdn.example.com/css/extrastyles.css" rel="stylesheet" type="text/css" />


NOTE:  In these 'plain old HTML' examples the assets would not be handled by the AXD, but we would expect them to be in the scenario of the RadStyleSheetManager.


The overall question rephrased then :  Is RadScriptManager capable of essentially making embedded resources out of stylesheets external to the root of a given web application?  &  If not, why not ?  & is this a planned enhancement ? 

0
Genady Sergeev
Telerik team
answered on 12 Mar 2013, 09:50 AM
Hi Karrie,

It is a limitation on our side that we don't allow for linking external resources (such as CDN resources) trough the StyleSheet manager. I will log that into our roadmap for RadStyleSheet manager.

As for the AXD handler - by design we  use the AXD handler only for embedded resources i.e. resources that are contained withing assembly. There is no real need to use it for resources that stay in a folder/CDN or something similar.

As a token of gratitude for pointing this problem to us I've updated you telerik points.

Greetings,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ScriptManager and StyleSheetManager
Asked by
Karrie
Top achievements
Rank 1
Answers by
Ivan Zhekov
Telerik team
Karrie
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or