Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3521
What is the correct HTML editor / persist paradigm?
posted

I thought that I understood how to persist text markup from the WebHTMLEditor to a database field and then reload the contents of the control later when it is requested.  But I figure based on the 'will not fix' response of my bug report, maybe I don't understand.  Or maybe the language barrier is getting in the way and the support team does not understand.  So, I thought that I would put it to a vote here.  For you IG folks, the BR number is BR31191.

Simple requirement really.  Just need to have a textbox with the ability to format text and not crash my server.  Kind of like the one that you have in the forum.  When the page loads again, I need to retrieve the contents from the database (in a varchar(max) field) and initialize the control.  I am using the .text property to do this since the .TextXHtml property is marked readonly.  In some scenarios, I have seen that what comes out of the control is not exactly what I put into it.  In fact, when it comes time to persist the markup back into the database, the markup I get out of the .TextXHtml property is often unbalanced, and in particular it likes to place extra unbalanced paragraph tags at the end of the markup and rip out certain other end tags in the middle and it always rips out the </body> and </html> tags at the end. 

When this happens repeatedly, the end result is our worker processes crashes at the time of reading the .TextXHtml property.  If this happens repeatedly, the entire application pool crashes due to the settings in the application pool.  In other words, I am saying that a bug in this control is bringing down my servers.

 I have not seen this happen in a scenario when the user originates and ends with text that they originated with the control.  Where I have seen it pop up most often is with text which was pasted in from Word or even Excel.  I have since taken steps to eliminate all markup upon pasting into the control, but what remains in the database is valid markup in the since that it would pass the validity checks of the ww3.  Yet, when using this 'valid markup' I think that it sometimes confuses the control because of how the tags are nested and what I get on the backend is not valid markup.  For comparison purposes of opening this ticket with IG, I prepared an example of HTML markup which passes the Visual Studio 2005 content editor checks.  I initialized the control (using the paradigm below) and with that valid markup.  Upon reading the contents of the control after I initialized it, I what I got back was markup with 14 errors.  This is not acceptable.

The number of errors are compounded later when the text with errors is persisted into the database.  For example, when I save those 14 errors to the database, if I later initialize the control with that markup with 14 errors, the next time I persist to the database I might get 50 errors.  The bottom line is either the control is buggy and IG won't admit it, or I am not understanding the paradigm. 

 So, in summary, the flow that I am using is below.  Do you recommend a different approach to initializing the contents with HTML markup and then reading the contents later?  Am I wrong to think that the .TextXHtml property should give me back exactly what I put into it?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not Me.IsPostBack Then

             Me.WebHTMLEditor1.Text = databasegetmethodresults

End If

End Sub

Private Sub btnGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGo.Click

Persisttodb(me.WebHTMLEditor1.TextXHtml)

End Sub

Parents
  • 425
    posted

    Something needs to be done about this, ASAP.

    If I have a simple bulleted list as follows:

    <ul>
    <li>Database upgrades</li></ul>

    When I read the .Text property the tags get converted to uppercase as follows:

    <UL>
    <LI>Database upgrades</LI></UL>

    This is not compliant. How can I maintain the formatting?

    Here's what http://validator.w3.org has to say about it:

    Error Line 221, Column 3: element "LI" undefined .

    <LI>Database upgrades</LI>

    You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by:

    • incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element),
    • by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).
    • by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case).

     

Reply Children
No Data