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

Change links in htm with Radeditor in c#

1 Answer 66 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 13 Jul 2012, 10:58 AM
Hi, I want to change htm's name and his links too, for this i'm trying to use radeditor, my question is, it's posible to modify links in htm with radeditor in c#?, i'm trying with this code:
 RadEditor1.Content = ReadFile(Server.MapPath("~/"+Root()+"/example.htm");
                    string mod = Root().Replace(" ", "%20");
                    RadEditor1.Content.Replace("href='"+mod,"href='"+NewRoot);
                     using (StreamWriter externalFile = new StreamWriter(Path.Combine(Server.MapPath("~/"+NewRoot), "Newexample.htm"), false, Encoding.UTF8))//Open file for writing and write content
                    {
                        externalFile.Write(RadEditor1.Content);
                    }
 protected string ReadFile(string path)
    {
        if (!System.IO.File.Exists(path))
        { return string.Empty; }//fin if file exists
        using (System.IO.StreamReader sr = new System.IO.StreamReader(path, Encoding.GetEncoding("macintosh")))
        { return sr.ReadToEnd(); }
    }
but I think that Replace() no work with html, please help me

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 17 Jul 2012, 01:44 PM
Hello,

If you want to update the links in RadEditor, you should do that on the client by implementing a custom content filter. If you want to do that on the server, you can do that after you obtain the RadEditor's content via the Content property. The Content property returns a standard string which you can modify using the String.Replace method and if needed regular expressions.

All the best,
Rumen
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
Editor
Asked by
Daniel
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or