Selectively use Absolute Paths in Cute Editor

Last post 09-20-2012, 9:32 AM by gordonjohnston. 2 replies.
Sort Posts: Previous Next
  •  09-20-2012, 4:46 AM 74706

    Selectively use Absolute Paths in Cute Editor

    I am using CuteEditor to compose Emails.

     

    My initial problem was that when the email is received in an inbox, the images don't work bacause they are Relative.

     

    I added "URLType='Absolute'" and that corrects that issue.

     

    However there are MessageGear links within the email which allow for Unsubscribe etc.  They are in the form "${Gears.unsubscribe()}">".

     

    However, this is prepended with the full path also, which breaks it.

     

    Any suggestions on what I should do to fix the problem. 

  •  09-20-2012, 7:52 AM 74707 in reply to 74706

    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 

  •  09-20-2012, 9:32 AM 74709 in reply to 74707

    Re: Selectively use Absolute Paths in Cute Editor

    Thanks very much.

     

    That has worked.

     

    Regards,

    Gordon 

View as RSS news feed in XML