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

Reading RadEditor content programmatically

1 Answer 76 Views
WebParts for SharePoint
This is a migrated thread and some comments may be shown as answers.
Sathya
Top achievements
Rank 1
Sathya asked on 06 May 2008, 03:06 PM
Hi,

When I read the contents of a page that contains content that uses RadEditor, I realized that the content is encrypted.

One of our needs is to generate a report with links in each file. Since content from RadEditor is encoded (such as multimedia or flash content embedded using the RadEditor), I am not able to get the references to those links by reading the page.

Is there an API within RadEditor that would give me the decrypted version of the content so that I can generate a report that tells me all the links within a page?

1 Answer, 1 is accepted

Sort by
0
Accepted
Lini
Telerik team
answered on 09 May 2008, 06:57 AM
Hi Sathya,

The API method you need is

Telerik.SharePoint.EditorTools.UnEscapeSpecialTags(string html)

However, I think that the EditorTools class is private so you will not be able to use it in this version. Here is the code you can use to decode the editor content:

public static string DecodeString(string nodeContent)  
{  
    try 
    {  
        byte[] byteContent = Convert.FromBase64String(nodeContent);  
        string b64Content = System.Text.Encoding.UTF8.GetString(byteContent);  
        return b64Content;  
    }  
    catch (Exception)  
    {  
        return nodeContent;  
    }  
}  
 
public static string UnEscapeSpecialTags(string html)  
{  
    MatchEvaluator meTags = new MatchEvaluator(DecodeMatch);  
    string fixedHtml = Regex.Replace(html, "<pre\\s+(style=\"display\\s*:none\"\\s*)?id=\"?RadEditorEncodedTag\"?[^>]*>([^<]+)</pre>", meTags, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.ECMAScript);  
    return fixedHtml;  
}  
 
public static string DecodeMatch(Match m)  
{  
    return DecodeString(m.Groups[2].Value);  
}  
 
 

Simply call UnEscapeSpecialTags() with the editor content.

Regards,
Lini
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
WebParts for SharePoint
Asked by
Sathya
Top achievements
Rank 1
Answers by
Lini
Telerik team
Share this question
or