CssClass dropdown automagically populated but stylesheet not applied to edit window

Last post 07-11-2008, 6:26 AM by Flintstone. 3 replies.
Sort Posts: Previous Next
  •  07-10-2008, 11:04 AM 42096

    CssClass dropdown automagically populated but stylesheet not applied to edit window

    I am trying to use the following code to populate CssClass:
     
    If Not ce.ToolControls("CssClass") Is Nothing Then
                ce.AutoParseClasses = True
                ce.EditorWysiwygModeCss = "~/css/style.aspx"
                ce.DisableClassList = "htmlEditor,tblbox"
    End If
     
    The dropdown is populated so style.aspx (dynamic stylesheet) must be getting loaded correctly.
     
    When the classes are applied to text in the editor window the HTML view shows <span class="MyClass">MyText</span> but the style is not applied from the stylesheet.
     
    So it seems that the stylesheet is not being applied to the editor window even though the CssClass dropdown is reading it successfully ... what am I doing wrong.
     
    BTW: I am using 6.1.0.0
  •  07-10-2008, 1:45 PM 42112 in reply to 42096

    Re: CssClass dropdown automagically populated but stylesheet not applied to edit window

  •  07-10-2008, 2:07 PM 42115 in reply to 42112

    Re: CssClass dropdown automagically populated but stylesheet not applied to edit window

    Hmmm ... unfortunately that would be awkward. I assume that this is a known problem and that calling it from OnInit would solve the problem.
     
    The problem is obviously that the stylesheet is not applied to the iframe. Is there any way to assign the new stylesheet to the iframe using Javascript?
  •  07-11-2008, 6:26 AM 42134 in reply to 42112

    Re: CssClass dropdown automagically populated but stylesheet not applied to edit window

    I have found a way to make this work:
     
    If I use the path /projectname/css/style.aspx it works so this issue seems to be caused by the tilde(~). From what I see the css attached to the frame has the path ~/blah/blah ... this path should really be expanded to the full path.
     
    Anyhow, I have a way that even lets me import external stylesheets:
    If I scrape the a css url using a local aspx page it is loaded fine and the dropdown is also automagically generated. This also works with dynamic stylesheets.
     
    e.g.
    To load http://cutesoft.net/themes/default/style/Common.css into the Classes Dropdown:
     
    url = "http://cutesoft.net/themes/default/style/Common.css"
    ce.EditorWysiwygModeCss = "/loadpage.aspx?url=" & System.Web.HttpUtility.UrlEncode(url)
     
    Like I say, using ~/loadpage.aspx does not work but using a relative path does.

     
    loadpage.aspx
    <%
    Dim url As String=Request.QueryString.Item("url")
    Dim text As String
    Dim tries As Integer = 2
    For n As Integer=1 to tries
      If len(text)=0 Then text = WebUtils.ReadURL(url)
    Next
    Response.Write(text)
    %>


    WebUtils.vb
    Class WebUtils
      Public Function ReadURL(ByVal url As String) As String
           Try
               Dim wc As New System.Net.WebClient
               Dim s As System.IO.Stream
               Dim sr As System.IO.StreamReader
               Dim text As String

               s = wc.OpenRead(url)

               sr = New System.IO.StreamReader(s)
               text = sr.ReadToEnd()

               sr.Close()
               s.Close()

               Return text
           Catch
               Return Nothing
           End Try
      End Function
    End Class

View as RSS news feed in XML