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

StyleSheetManagerProxy

3 Answers 101 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Dustin
Top achievements
Rank 1
Dustin asked on 23 Nov 2010, 07:28 PM
I started using the RadStyleSheetManager and realized that it is more of a pain to use then not use since there is no proxy version. So I created a custom StyleSheetManagerProxy control that can be used in combination with the RadStyleSheetManagerProxy similar to the RadScriptManager and ScriptManagerProxy.

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.PersistenceModeAttribute

Namespace CustomControls

    <ParseChildren(True)>
    <PersistChildren(False)>
    Public Class StyleSheetManagerProxy
        Inherits Control

#Region "Events"

        Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
            Dim rssm As RadStyleSheetManager = RadStyleSheetManager.GetCurrent(Me.Page)
            If rssm IsNot Nothing Then Me.StyleSheets.ToList().ForEach(Sub(i) rssm.StyleSheets.Add(i))
            MyBase.OnLoad(e)
        End Sub

#End Region

#Region "Properties"

        Private m_StyleSheets As StyleSheetReferenceCollection

        <PersistenceMode(PersistenceMode.InnerProperty)>
        <DefaultValue(CType(Nothing, String))>
        <MergableProperty(False)>
        Public ReadOnly Property StyleSheets As StyleSheetReferenceCollection
            Get
                If m_StyleSheets Is Nothing Then m_StyleSheets = New StyleSheetReferenceCollection()
                Return m_StyleSheets
            End Get
        End Property

#End Region

    End Class

End Namespace

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 24 Nov 2010, 01:52 PM
Hello Dustin,

Thank you for sharing your thoughts about the StyleSheetManagerProxy class.

Your implementation will suffice in cases one needs to add embedded style sheets in a Content page or a UserControl. The other would be to directly add the settings programmatically to the StyleSheetManager's StyleSheet collection.

Currently we do not have plans for adding such a control to the suite, still we will reconsider your suggestion in the future.

All the best,
Simon
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Simon
Top achievements
Rank 1
answered on 12 Apr 2012, 05:35 PM
Thanks for this code, we've found it really useful, especially when declaritively referencing external style sheets from pages nested within multiple Masterpages.

Pity that the Telerik library doesn't have this functionality built in, or indeed any method to control the stylesheet order relative to existing standard linked stylesheets.It always adds to the bottom of the head tag, and therefore has to the potential to override existing stylesheets.
0
Shark75
Top achievements
Rank 2
answered on 04 Feb 2014, 02:32 PM
Wow, thanks for the code, that's really useful. It's disappointing that this proxy isn't in the Telerik RadControls library as it would be very useful.
Tags
ScriptManager and StyleSheetManager
Asked by
Dustin
Top achievements
Rank 1
Answers by
Simon
Telerik team
Simon
Top achievements
Rank 1
Shark75
Top achievements
Rank 2
Share this question
or