asp.net consultancy chorley ASP.NET Server Side Scripting Wigan
Website Development Radcliffe

IT Services And Support

Email : ren@techsolus.co.uk
Mobile Phone : 0788 68 41 411
Answerphone : 01204 469683
bespoke invoice systems Standish Information Technology Advice Worsley
    development systems Ramsbottom
data manipulation Farnworth access databases Whitefield SQL connections Atherton
online accessible software Leyland software compatible Coppull


Get connected and Online Tottington
remote management Makerfield code and design Aspull

FCK Editor, Opera, New Lines, Line Breaks, ASP.NET - 24/02/2011

FCK Editor uses Javascript for the editing box...

I use ASP.net to store the contents greated in FCK Editor...

I use ASP.net to retrieve and edit the contents of the FCK Editor...

Here's the problem...

FCK Editor takes my input and in the background creates HTML.  FCK Editor kind of works like an online Javascript version of Frontpage or Dreamweaver, just a lot lot lot simpler.  That HTML contains line breaks, new lines and carriage returns etc etc etc. 

That is not an issue.  HTML code ignores line breaks.  ASP.net will take the full string of HTML, line breaks and all, and happily store it in my database as a string.  I can later retrieve that string from the database, line breaks included, and place that string back into the FCK Editor javascript so I can further edit and alter the string.

Only Javascript does NOT approve of line breaks, carriage returns or new lines. 

So this WILL work

<script type="text/javascript">

<!--

var oFCKeditor = new FCKeditor( 'descf' ) ;
oFCKeditor.BasePath = 'http://www.techsolus.co.uk/cms/fckeditor/' ;
oFCKeditor.Height = 500 ;
oFCKeditor.Width = 800 ;
oFCKeditor.Value = 'THIS IS THE TEXT I WISH TO EDIT THIS IS THE TEXT I WISH TO EDIT ' ;
oFCKeditor.Create() ;
//-->

</script>

This will NOT work

<script type="text/javascript">

<!--

var oFCKeditor = new FCKeditor( 'descf' ) ;
oFCKeditor.BasePath = 'http://www.techsolus.co.uk/cms/fckeditor/' ;
oFCKeditor.Height = 500 ;
oFCKeditor.Width = 800 ;
oFCKeditor.Value = 'THIS IS THE TEXT I WISH TO EDIT
THIS IS THE TEXT I WISH TO EDIT
' ;
oFCKeditor.Create() ;
//-->

</script>

The point being that the line break in the editing part of the FCK Editor Javascript cannot be over more than one line.  So we need to remove any line breaks in the editable string.  In ASP.net this should be realy simple

editstring = replace(editstring, vbcrlf, " ")

And for the most part, this worked.  Then I started to use Opera to edit some of my FCK Editor driven websites.  It seems Opera does not send the line breaks or carriage returns with quite the same string.  After much searching I found this solution

editstring = replace(editstring, vbcrlf, " ")
editstring = replace(editstring, chr(10), " ")

This removes the new lines that Opera seems to place in there.  You can also try...

editstring = replace(editstring, vbcrlf, " ")
editstring = replace(editstring, chr(10), " ")
editstring = replace(editstring, chr(13), " ")
editstring = replace(editstring, chr(10) & chr(13), " ")
editstring = replace(editstring, "\r", " ")
editstring = replace(editstring, "\n",  " ")

So you're looking for vbcrlf, chr(10) and chr(13), \r and \n...if you know of any more let me know too...
  The joy of a lack of standards...or too many





Post A Comment

Name Comment
programming services asp.net specialist
Valid XHTML 1.0 Transitional
Admin
GD