How to avoid illegal / invalid HTML Code

  •  07-29-2009, 2:54 AM

    How to avoid illegal / invalid HTML Code

    Hi all,
     
    the problem is not caused directly by CuteEditor but the data is added using CuteEditor so I hope there is a solution:
     
    How could I check whether the entered text is valid HTML? Sometimes my users enter invalid HTML without knowing, e.g. a text like
     
    <!-- Test />
     
    (The tag is not closed correct, the end is wrong. The correct tag would be: <!-- Test --> )
     
    That's not a problem when they paste it into the default text window, but it might happen that they paste it on the HTML-Tab. In this case the data is not encoded to valid html which would be
     
    &lt;!-- Test /&gt;
     
    (Same happens when they are in the default tab and select 'Paste as HTML')
     
    So technically it's correct from CuteEditor: It's pasted as HTML and accepted and saved. But later on I want to display the entered text, and thats the problem now: The browser (IE 6) stops with an error:
     
    Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element
     
    I tried to reproduce on your demo page but you only output the entered text in HTML-Code using HTMLEncode, so that's not a problem.
     
     
    So as said, it's not directly a problem of CuteEditor, but several others might have the same problem so I hope there is a solution, like checking whether HTMLCode is valid without disabling the HTML-Functionality completely because some other users really need that.
     
    Many thanks in advance!
     
    I wonder how it's done here in the forum because in the HTML-Code I added the above mentioned invalid code and at least the preview is still working fine....
    .net Framework 4.0 / ASP.net / VB / CuteEditor 6.7 / SQL 2005
    Filed under:
View Complete Thread