Re: CleanUpMicrosoftWordHTML() automatically adds CDATA to my script tags

  •  07-30-2010, 1:00 AM

    Re: CleanUpMicrosoftWordHTML() automatically adds CDATA to my script tags

    Hi Ken,
    Unfortunately the demo strips the script tags from the input. What I did was basically: 
    1) Allow client scripts in the document
    2) Call CleanUpMicrosoftWordHTML()
    3) Display the editor's Text property after the clean up. 
     
    I can't seem to include an attachment, so i'll just put a modified default.aspx in a code block here: 
    1. <%@ Page Language="C#"%>  
    2. <%@ Register TagPrefix="cutesoft" TagName="banner" Src="banner.ascx" %>  
    3. <%@ Register TagPrefix="cutesoft" TagName="leftmenu" Src="leftmenu.ascx" %>  
    4. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>  
    5. <html>  
    6.     <head>  
    7.         <title>ASP and ASP.NET WYSIWYG Editor - Default Configuration </title>  
    8.         <link rel="stylesheet" href="../example.css" type="text/css" />  
    9.     </head>  
    10.     <body>  
    11.         <form runat="server">  
    12.             <cutesoft:banner id="banner1" runat="server" />     
    13.             <table cellpadding="15">  
    14.                 <tr>  
    15.                     <td id="leftcolumn" width="160">  
    16.                         <cutesoft:leftmenu id="leftmenu1" runat="server" />                 
    17.                     </td>  
    18.                     <td>  
    19.                         <h1>Enable All Toolbars</h1>  
    20.                         This example show you <b>all the predefined buttons</b>. <br /><br />                                     
    21.                         <asp:radiobuttonlist id="ConfigureList" runat="server" autopostback="True" RepeatDirection="Horizontal" onselectedindexchanged="Configure_Changed">  
    22.                             <asp:ListItem value="Full">Full</asp:ListItem>  
    23.                             <asp:ListItem value="Full_noform">Full_noform</asp:ListItem>  
    24.                             <asp:ListItem value="Default" Selected="True">Default</asp:ListItem>  
    25.                             <asp:ListItem value="Compact">Compact</asp:ListItem>  
    26.                             <asp:ListItem value="Simple">Simple</asp:ListItem>  
    27.                             <asp:ListItem value="Minimal">Minimal</asp:ListItem>  
    28.                             <asp:ListItem value="None">None</asp:ListItem>  
    29.                         </asp:radiobuttonlist>  
    30.                         <CE:Editor id="Editor1" EditorWysiwygModeCss="../example.css" runat="server" ></CE:Editor><br />  
    31.                         <asp:Button id="btnUpdate" onclick="Submit" Runat="server" Text="Show HTML"></asp:Button>  
    32.                         <asp:Literal ID="Literal1" Runat="server" />  
    33.                     </td>  
    34.                 </tr>  
    35.             </table>            
    36.         </form>  
    37.     </body>  
    38. </html>  
    39.   
    40. <script runat="server">  
    41.     void Page_Load(object sender, System.EventArgs e)  
    42.      {  
    43.         // don't strip script tags  
    44.         Editor1.EnableStripScriptTags = false;  
    45.           
    46.         if (IsPostBack)   
    47.         {   
    48.             // call cleanup...  
    49.             Editor1.CleanUpMicrosoftWordHTML();  
    50.               
    51.             Literal1.Text = "<h2>The HTML you typed is...</h2><br>";   
    52.               
    53.             // set to Literal1  
    54.             Literal1.Text += Server.HtmlEncode(Editor1.Text);             
    55.         }   
    56.         else   
    57.         {   
    58. //          Editor1.Text = "Type Here";  
    59.             Editor1.Text = @"<table cellspacing=""4"" cellpadding=""4"" bgcolor=""#ffffff"" border=""0""> <tbody> <tr> <td> <p> <img src=""http://cutesoft.net/Uploads/j0262681.jpg"" width=""80"" alt=""""/></p></td> <td> <p>When your algorithmic and programming skills have reached a level which you cannot improve any further, refining your team strategy will give you that extra edge you need to reach the top. We practiced programming contests with different team members and strategies for many years, and saw a lot of other teams do so too.  </p></td></tr> <tr> <td> <p>  <img src=""http://cutesoft.net/Uploads/PH02366J.jpg"" width=""80"" alt="""" /></p></td> <td> <p>From this we developed a theory about how an optimal team should behave during a contest. However, a refined strategy is not a must: The World Champions of 1995, Freiburg University, were a rookie team, and the winners of the 1994 Northwestern European Contest, Warsaw University, met only two weeks before that contest.  </p></td></tr></tbody></table> <br /> <br />";   
    60.         }   
    61.       
    62.     }  
    63.     public void Submit(object sender, System.EventArgs e)  
    64.     {  
    65.         Literal1.Text = "<h2>The HTML you typed is...</h2><br>";   
    66.         Literal1.Text += Server.HtmlEncode(Editor1.Text);   
    67.     }  
    68.       
    69.     private void Configure_Changed(Object sender, EventArgs e)  
    70.     {  
    71.         switch(ConfigureList.SelectedItem.Value)  
    72.         {  
    73.             case "Full":  
    74.                 Editor1.AutoConfigure  = AutoConfigure.Full;  
    75.                 break;  
    76.                   
    77.             case "Compact":  
    78.                 Editor1.AutoConfigure  = AutoConfigure.Compact;  
    79.                 break;  
    80.                   
    81.             case "Full_noform":  
    82.                 Editor1.AutoConfigure  = AutoConfigure.Full_noform;  
    83.                 break;  
    84.                   
    85.             case "Simple":  
    86.                 Editor1.AutoConfigure  = AutoConfigure.Simple;  
    87.                 break;  
    88.                   
    89.             case "Minimal":  
    90.                 Editor1.AutoConfigure  = AutoConfigure.Minimal;  
    91.                 break;  
    92.                   
    93.             case "None":  
    94.                 Editor1.AutoConfigure  = AutoConfigure.None;  
    95.                 break;  
    96.         }     
    97.     }  
    98. </script> 
     
     
     
    As an example, if you type into the editor in HTML mode: 
    <script type="text/javascript">alert('hi!');</script>
     
    you'll see that alert('hi!'); is encased with a CDATA block.
     
     
    I'd like to have the option of disabling this behaviour. Thanks!
View Complete Thread