Re: Selectively use Absolute Paths in Cute Editor

  •  09-20-2012, 7:52 AM

    Re: Selectively use Absolute Paths in Cute Editor

    Hi gordonjohnston,

     

    For now the editor does not support to separate the image/link url format. We suggest you change the link url to the relatively path before you send the mail at server side.

     

    Please try the example below, it shows you how to replace the path of the link(only for <a> target) at server side.

     

    1. <%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" %>  
    2.   
    3. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5.   
    6. <script runat="server">  
    7.     string FilterHref(Match m)  
    8.     {  
    9.         string href = m.Groups[3].ToString();  
    10.         string pre = "http://localhost:14123";  
    11.         if (href.StartsWith(pre))  
    12.             href = href.Remove(0, pre.Length);  
    13.         return "<a " + m.Groups[1] + "href=" + m.Groups[2] + href + m.Groups[4];  
    14.     }  
    15.   
    16.     protected void b1_Click(object sender, EventArgs e)  
    17.     {  
    18.         Regex re = new Regex("<a\\s([^>]+\\s)?href\\s?=\\s?([\"']?)([^>\"']+)([\"']?)", RegexOptions.Compiled | RegexOptions.IgnoreCase);  
    19.         t1.Text = re.Replace(Editor1.Text, new MatchEvaluator(FilterHref));  
    20.     }  
    21. </script>  
    22.   
    23. <html xmlns="http://www.w3.org/1999/xhtml">  
    24. <head id="Head1" runat="server">  
    25.     <title></title>  
    26. </head>  
    27. <body>  
    28.     <form id="form1" runat="server">  
    29.         <CE:Editor ID="Editor1" runat="server" URLType="Absolute">  
    30.         </CE:Editor>  
    31.         <asp:Button ID="b1" runat="server" Text="save" OnClick="b1_Click" /><br />  
    32.         <asp:TextBox ID="t1" runat="server" TextMode="multiLine" Rows="20" Width="800"></asp:TextBox>  
    33.     </form>  
    34. </body>  
    35. </html>  
     

    The code below use to defined the url which you do not want it in the <a> target. “http://localhost:14123” is my host name.

     

    string pre ="http://localhost:14123";

     

    Regards,

     

    Ken 

View Complete Thread