CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

Last post 11-05-2008, 3:56 PM by rktekula. 12 replies.
Sort Posts: Previous Next
  •  11-01-2008, 4:37 AM 45280

    CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!


     
    Hi I have the following code in aspx page.
     
    <CE:Editor ID="txtGoalDesc" runat="server" AllowEditServerSideCode="true" ResizeMode="AutoAdjust"  DisableItemList="Save" RenderRichDropDown="true"  ShowBottomBar="true"  Width="100%"  ThemeType="Office2007"   AutoConfigure="Full" ></CE:Editor>
     
    In code behind, while saving to the database, I want to remove word specific HTML and all messy HTML. So I am doing like this
     
                txtGoalDesc.CleanUpMicrosoftwordHTML();
                txtGoalDesc.CleanUpHTML();
     
      Then saving txtGoalDesc.Text to the database.
     
     But There is no difference between the editor text before and after using the above cleanup functions. I am still having the word and messy HTML in my final txtGoalDesc.Text.  But If I use the cleanup tool of the editor manually, it does.
     
     Do we need any extra settings to use the above functions ? I am struck here. I have my deadline to client on this monday 11/03/2008. Please help.
     
    Please help. Thanks in advance.
     
     
    Rama
     
             
  •  11-01-2008, 9:31 AM 45287 in reply to 45280

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

    Rama, 
     
    We have an online example to test the Editor.CleanUpHTMLCode().
     
     
    Keep me posted

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  11-01-2008, 1:51 PM 45290 in reply to 45287

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

    Thanks Adam for the reply.  I appreciate your help.
     
    But I want to remove word HTML.
     
    txtGoalDesc.CleanUpMicrosoftWordHTML() is not doing any thing for  me.
     
    I pasted a table from MS Word in to the editor. Then I want to remove MS word HTML from it.
    So through code am doing CleanUpMicrosoftwordHTML(). But it is doing nothing.
     
    If I use the Clean Up tool of the editor, then if I see the HTML , it is removing all word html. But not working through code.
     
    Thanks,
     
     appreciate your patience.
     
     
       
     
     
  •  11-01-2008, 2:19 PM 45291 in reply to 45290

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

     
     Adam, What I wanted you to observe is the CleanUp Tool of the editor( with option Remove word specific HTML from the window)  and CleanUpMicrosoftWordHTML() through code are not working exactly same.
     
     1. Paste something (preferably tables)  from the ms word in to the editor.
     2. Execute CleanUpMicrosoftwordHTML() through code on the editor.
     3. Then see the HTML
     
     Now again try with CleanUp Tool of the editor. Then see the html of the editor from bottom toolbar.
     
     Both HTML does'nt look same. There is lot of difference.
     
     CleanUp Tool is removing all word html but through code it is not.
     
     
     But What I want is the functionaliy of CleanUp Tool. I can't ask users to use the tool always.
     
     Thanks
  •  11-03-2008, 12:23 AM 45300 in reply to 45291

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

  •  11-03-2008, 12:29 AM 45302 in reply to 45300

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

     Hi Adam,
     
                 Yes Adam. this is the result what I observed. Both does'nt work same. Can you check this please ?
  •  11-03-2008, 12:35 AM 45304 in reply to 45302

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

  •  11-03-2008, 1:04 AM 45308 in reply to 45304

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

    Cell 1

    Cell 2

    Cell 3

    Cell 21

    Cell 22

    Cell 23

     
    THis is the sample table which I am working on
     
     
    Below is the HTML I am getting with using Clean up HTML tool(brush icon) in the editor toolbar and clicking on "Remove word specific markup"


    <table cellspacing="0" cellpadding="0" border="1">
        <tbody>
            <tr>
                <td valign="top" width="213">
                <p><font face="Calibri">Cell 1 </font></p>
                </td>
                <td valign="top" width="213">
                <p><font face="Calibri">Cell 2 </font></p>
                </td>
                <td valign="top" width="213">
                <p><font face="Calibri">Cell 3</font></p>
                </td>
            </tr>
            <tr>
                <td valign="top" width="213">
                <p><font face="Calibri">Cell 21</font></p>
                </td>
                <td valign="top" width="213">
                <p><font face="Calibri">Cell 22</font></p>
                </td>
                <td valign="top" width="213">
                <p><font face="Calibri">Cell 23</font></p>
                </td>
            </tr>
        </tbody>
    </table>



    Below is the HTML I am getting with the server side method editor.CleanUpMicrosoftWordHTML()



      <table class="MsoTableGrid" style="border-right: medium none; border-top: medium none; margin: auto auto auto 0.5in; border-left: medium none;

    border-bottom: medium none; border-collapse: collapse;

    " cellspacing="0" cellpadding="0" border="1">
        <tbody>
          <tr>
            <td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: black 1pt solid; padding-left: 5.4pt; padding-bottom: 0in; border-left:

    black 1pt solid; width: 159.6pt; padding-top: 0in; border-bottom: black 1pt solid; background-color: transparent;

    " valign="top" width="213">
              <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt; line-height: normal;">
                <font face="Calibri">Cell 1 </font>
              </p>
            </td>
            <td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: black 1pt solid; padding-left: 5.4pt; padding-bottom: 0in; border-left:

    #ece9d8; width: 159.6pt; padding-top: 0in; border-bottom: black 1pt solid; background-color: transparent;

    " valign="top" width="213">
              <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt; line-height: normal;">
                <font face="Calibri">Cell 2 </font>
              </p>
            </td>
            <td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: black 1pt solid; padding-left: 5.4pt; padding-bottom: 0in; border-left:

    #ece9d8; width: 159.6pt; padding-top: 0in; border-bottom: black 1pt solid; background-color: transparent;

    " valign="top" width="213">
              <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 0pt; line-height: normal;">
                <font face="Calibri">Cell 3</font>
              </p>
            </td>
          </tr>
          <tr>
            <td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: #ece9d8; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt

    solid; width: 159.6pt; padding-top: 0in; border-bottom: black 1pt solid; background-color: transparent;

    " valign="top" width="213">
              <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt; line-height: normal;">
                <font face="Calibri">Cell 21</font>
              </p>
            </td>
            <td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: #ece9d8; padding-left: 5.4pt; padding-bottom: 0in; border-left: #ece9d8;

    width: 159.6pt; padding-top: 0in; border-bottom: black 1pt solid; background-color: transparent;

    " valign="top" width="213">
              <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt; line-height: normal;">
                <font face="Calibri">Cell 22</font>
              </p>
            </td>
            <td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: #ece9d8; padding-left: 5.4pt; padding-bottom: 0in; border-left: #ece9d8;

    width: 159.6pt; padding-top: 0in; border-bottom: black 1pt solid; background-color: transparent;

    " valign="top" width="213">
              <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 0pt; line-height: normal;">
                <font face="Calibri">Cell 23</font>
              </p>
            </td>
          </tr>
        </tbody>
      </table>



    Now my question is both these does't do the same job as mentioned in the site in this link

    http://cutesoft.net/example/CommonTasks.aspx under HTML Filtering options
     
     
    Regards
    Rama

     
     
     
     
  •  11-03-2008, 1:09 PM 45337 in reply to 45308

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

    Rame,
     
    The clean up funtion in the editor toolbar is a client funtion. It will remove all inline styles and css classes from the code.
     
    Editor.CleanUpMicrosoftWordHTML Method is a server side funtion. It will only remove Microsoft Word related HTML code. And it will leave the Css classes and inline styles.
     
    Editor.CleanUpMicrosoftWordHTML Method
    Use the Clean Up Word HTML function to remove the extraneous HTML code generated by Microsoft Word.
     
    If you think you should remove the Css classes and inline styles,  just write some regular expressions to remove those code.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  11-03-2008, 2:39 PM 45339 in reply to 45337

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

     
     Thanks Adam for the reply. I appreciate your help on this.
     
       Our whole production team has struck here. We can't proceed further. We are facing lot of issues with the users today.
     
      Can you help me in writing the code to clean up all the inline styles and Css classes ?
     
       I want the exact functionality of CleanUp Tool (brush icon) of the toolbar with option 'Remove WordSpecific Markup'
     
      How can I acheive this ? I know I should write a regular expression but I am very poor in it. I want to call your javascript function of CleanUp Tool on the client.  I have gone through the cutesoft  javascript file Dialog_Clean.js which has javascript function "Codecleaner(editor)"
     
     
     This is the way I want to do in server side in C#.Net 2.0
     
      private  string CustomCleanHTML(editor1.text)
     
     {
            //here I should write the code for removing inline styles and Css classes.
     
           
     
            return strCleanText;
       
     }
     
     
     
  •  11-03-2008, 7:02 PM 45345 in reply to 45339

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

     For acheiving the above thing I am doing the following......
     
     
     <script language="javascript">

     var OxO2f01=["ig",

    "\x3C/?[^\x3E]*\x3E",

    "",

    "\x3C\x5C?xml[^\x3E]*\x3E",

    "\x3C/?[a-z]+:[^\x3E]*\x3E",

    "(\x3C[^\x3E]+) class=[^ |^\x3E]*([^\x3E]*\x3E)",

    "$1 $2",

    "(\x3C[^\x3E]+) style=\x22[^\x22]*\x22([^\x3E]*\x3E)",

    "\x3Cspan[^\x3E]*\x3E\x3C/span[^\x3E]*\x3E",

    "\x3Cspan\x3E\x3Cspan\x3E",

    "\x3Cspan\x3E",

    "\x3C/span\x3E\x3C/span\x3E",

    "\x3C/span\x3E",

    "[ ]*\x3E",

    "\x3E",

    "\x3C/?font[^\x3E]*\x3E",

    "\x3C/?span[^\x3E]*\x3E",

    "span",

    "font",

    "css",

    "word",

    "allhtml"];

     

    function execRE(Ox276,Ox277,Ox132){

    var Ox278= new RegExp(Ox276,OxO2f01[0x0]);

    return Ox132.replace(Ox278,Ox277);} ;

     

     

     



    function
    customCleaner(controlID){

     

    var control = document.getElementById(controlID);

    alert("hii");                                                              //If I remove this alert message , this is not called.
     
    var editor = CuteEditor_GetEditor(control);

    var Ox132=editor.GetBodyInnerHTML();

     

     

     

    switch("word"){

     

    case OxO2f01[0x14]: Ox132=execRE(OxO2f01[0x3],OxO2f01[0x2],Ox132) ; Ox132=execRE(OxO2f01[0x4],OxO2f01[0x2],Ox132) ; Ox132=execRE(OxO2f01[0x5],OxO2f01[0x6],Ox132) ; Ox132=execRE(OxO2f01[0x7],OxO2f01[0x6],Ox132) ; Ox132=execRE(OxO2f01[0x8],OxO2f01[0x2],Ox132) ; Ox132=execRE(OxO2f01[0x9],OxO2f01[0xa],Ox132) ; Ox132=execRE(OxO2f01[0xb],OxO2f01[0xc],Ox132) ; Ox132=execRE(OxO2f01[0xd],OxO2f01[0xe],Ox132) ;break ;

    ;;;;

    } ;

     

    editor.SetHTML(Ox132) ;} ;
     
    </script>
     
     
    The above javascript is in my .aspx file. I have three text editors on the aspx page.
     
     
    In the code behind,
     
          I am looping through all the controls, finding the cute eidtor and passing the editor ID to the javascript function
     
      
    RemoveWordHTML is the function in code behind. I am passing Page as the parameter. So this will loop through all the controls and identify the cute editors and calling the above javascript function.


    public
    void RemoveWordHTML(System.Web.UI.Control cntrls)

    {

    CuteEditor.Editor TBText;

     

    foreach (System.Web.UI.Control cntrl in cntrls.Controls)

    {

    if (cntrl != null)

    {

    if (cntrl.GetType().ToString() == "CuteEditor.Editor")

    {

    if (cntrl.ID.ToString().IndexOf("CuteEditor") != -1)

    {

    TBText = (CuteEditor.Editor)cntrl;

    i++;

    string strScript = "<script language=javascript>customCleaner('" + TBText.ClientID + "');</script>";

    if (!Page.ClientScript.IsStartupScriptRegistered("clientScript" + i))

    Page.ClientScript.RegisterStartupScript(this.GetType(), "clientScript" + i, strScript);

     

    }

    }

    }

    if (cntrl.HasControls())

    {

    RemoveWordHTML(cntrl);

    }

    }

    }
     
     
    By doing the above , I am acheiving what I needed. ( Functionaliy of client side CleanUp Tool on server side). 
     
    But only If have some alert message then only javascript function is being called. I think it has something to do with funtion CuteEditor_GetEditor(control); 
     
    can you help me on this ?  Your patience is greatly appreciated !!
              
     
  •  11-03-2008, 10:31 PM 45346 in reply to 45339

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!


    private  string CustomCleanHTML(string html)
     
     {   
     
            return Regex.Replace(html, @"<([^>]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s>]+)([^>]*)>","<$1$2>", RegexOptions.IgnoreCase);
       
     }

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  11-05-2008, 3:56 PM 45438 in reply to 45346

    Re: CleanUpMicrosoftwordHTML() does'nt do any thing on my editor text. Please help urgent !!

     
     Thanks Adam....It worked.....I appreciate all your patience....
View as RSS news feed in XML