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

scrubbing comments

3 Answers 64 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Albert Shenker asked on 20 May 2013, 12:53 PM
Can anyone suggest a way of scrubbing the comments content created by rad editor without loading the content in Rad Editor and using the built-in Remove All toolbar button? Ideally this would be done server-side on some piece of content.

3 Answers, 1 is accepted

Sort by
0
Elliott
Top achievements
Rank 2
answered on 20 May 2013, 08:49 PM
yes
pump the content into an XDcoument (add a <root> and a </root> to the front and back, which you will remove at the end)
use XPath navigator to locate nodes that are comments - I looked and it seemed that they are
<span RadEditor: title='actual comment'> text being commented on</span>
replace the span node with the text being commented on (or the <span...> with just a <span> - remove the attributes?
or you could do it with string replaces
0
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 21 May 2013, 12:56 PM
unfortunately my xml processing skills are not that sharp. I wonder if Telerik has an example of doing this. Surely they must do something similar in order to remove the comments when users click on the "Remove Al comments" button.
0
Elliott
Top achievements
Rank 2
answered on 22 May 2013, 02:08 PM
this should get you started
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="RadEditorComments.aspx.vb" Inherits="RadEditorComments" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadAjaxManager ID="raManager" runat="server" />
<telerik:RadscriptManager ID="rsManager" runat="server" />
<table>
<tr>
<td>
    <telerik:RadEditor ID="rdEditor" EnableComments="true" runat="server">
    </telerik:RadEditor>
</td>
</tr>
<tr>
<td align="right">
    <telerik:RadButton ID="rbGo" Text="Go" runat="server" Height="22px" />
</td>
</tr>
</table>
</form>
</body>
</html>
Imports System.Xml
 
Partial Class RadEditorComments
    Inherits System.Web.UI.Page
 
    Protected Sub rbGo_Click(sender As Object, e As System.EventArgs) Handles rbGo.Click
        Dim theBody As XmlDocument
        Dim someNodes As XmlNodeList = Nothing
        Dim ANode As XmlNode = Nothing
        Dim sb As StringBuilder = Nothing
 
        sb = New StringBuilder("<root>")
        sb.Append(rdEditor.Content)
        sb.Append("</root>")
        theBody = New XmlDocument
        theBody.LoadXml(sb.ToString)
        someNodes = theBody.SelectNodes("/root/span[@title]")
        For Each ANode In someNodes
            ANode.Attributes.RemoveAll()
        Next
        sb = New StringBuilder(theBody.OuterXml)
       ' remove the <root> and </root>
        sb.Remove(0, 6)
        sb.Remove(sb.Length - 7, 7)
    End Sub

use sb.tostring as the body of your email
this may need tweaking to accommodate styling
Tags
Editor
Asked by
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Answers by
Elliott
Top achievements
Rank 2
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Share this question
or