This is a migrated thread and some comments may be shown as answers.

Invalid characters appended to text in radeditor

5 Answers 141 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Informat
Top achievements
Rank 1
Informat asked on 29 Jan 2009, 10:20 AM
After entering the text (for instance one word of 5 characters long) in a radeditor, the text is saved to the database.
However the text that is inserted into the database contains 5 characters + two extra characters.
If the inserted text is shown in a radgrid i get a javascript error because of the 2 extra characters that were saved to the database ( i guess something like cr/lf).
How can I prevent that radeditor stores these extra characters ?

Kind regards,
N.

5 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 02 Feb 2009, 03:04 PM
Hi Nick,

Please, see the following KB article which could be helpful for your scenario:
"\r\n" being added to content when submitted.


Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ManniAT
Top achievements
Rank 2
answered on 08 Mar 2009, 03:16 PM
Hi,

I read the article you linked - but this is not a solution.
I use RadEditor in a Grid - and this for a number of columns.

Question: When do I have to call this "RadEditorX.Content..."

I guess somewhere in grid's Update.
The next thing - neither the replace nor the trim really help.

The Reason - I have (needed) \r\n in the content.
Trim is no solution - my Text sometimes needs a trailing blank!!

By the way - how does this "bring better readability"?
In a normal DataEditor (VS built in or so) I see 2 rectangles on the end of the line.
In a WinForm I get an extra blank line consuming space on the form.
In ASP Grids it is simply ignored.
If I use the string for a confirm I get "unterminated string constant" and a lot of other things like this.

I would be great if this "feature" could be (declarative) turnded of.

Just my 2 Cents

Manfred
0
Rumen
Telerik team
answered on 11 Mar 2009, 05:01 PM
Hi Manfred,

Here is an example demonstrating how to access the RadEditor control:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        GridEditFormItem item = e.Item as GridEditFormItem;
        if (item != null && item.IsInEditMode)
        {
            GridHTMLEditorColumnEditor editor = item.EditManager.GetColumnEditor("myEditorColumn") as GridHTMLEditorColumnEditor;
            string content = editor.Editor.Content;
        }
    }

If you want you can also access it in the ItemDataBound event handler.

All the best,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ManniAT
Top achievements
Rank 2
answered on 11 Mar 2009, 05:17 PM
Hi,

thanks for the information - maybe I was unclear (I no native english writer :)).
I asked:

>>Question: When do I have to call this "RadEditorX.Content..."
>>I guess somewhere in grid's Update.

So I should have better asked WHERE or so.
Because getting the content when the item is created does not help.
At this time the string is OK - it becomes "destroyed" by the editor after editing - or from an other perspective BEFORE storing to my database.
Anyhow - I hate to call useless handlers in ASPX - so I decided to move the things to SQL-Server.
And there I had to write some "nasti looking" trigger - but anyhow it removes the crap the editor adds.

Except sometimes it also adds unicode(160) a kind of blank in front of the \r\n - but I'm not sure when this happens.

Just to show - here is my "anti radeditor trigger" :))
ALTER TRIGGER dbo.TRStringsLocINSUPD  
ON dbo.StringsLoc  
FOR INSERT, UPDATE  
AS  
    SET NOCOUNT ON  
    UPDATE StringsLoc SET TheString=CASE WHEN SUBSTRING(TheString, LEN(TheString)-1,2)=NCHAR(13)+NCHAR(10) THEN RTRIM(SUBSTRING(TheString, 1,LEN(TheString)-2)) ELSE TheString END WHERE StringsID IN (SELECT StringsID FROM INSERTED)  
 
By the way - I know a join would be better than a "where in select" - but this function is seldom called - and it looks bad enogh in this fashion.

By the way - doing this I can allways be shure that nothing "bad" reaches (OK it reaches - but it get's corrected immideately)
in (for an example) the case that I (or an employee) forget to add a (I guess) update handler on a page where content is edited via RadEditor.

Please do not misunderstand me -- I think your editor is one of the best out there.
I just do not confirm with your "better readability by adding content without asking".
Of courses we could discuss about the readability (I gave some negative samples in the post before).
BUT - I'm not willing to discuss about an editor that adds stuff - without the ability to turn this of.

Maybe you could think about this for a later release - it would mean nothing more than a boolean property
"DoNotAddFreakingStuff" which defaults to false - so the editor does still what it does now -
until an ugly customer comes up and set's it to true in designtime :)))


Regards

Manfred
0
Tervel
Telerik team
answered on 24 Mar 2009, 04:17 PM
Hello Manfred,

We added to our TODO list that no trailing \r\n symbols should be added to the end of the content.

To answer your question about the increased readability - the \r\n at the end are in fact a side effect of one of the 20+ RadEditor content filters that aim to correct various browser deficiencies and produce XHTML content. One of thos filters is charged with the purely visual task of indenting raw HTML content (e.g. making sure that TD's are indented deeper than parent TR's,  LI's are indented more than UL's etc). This filter uses regular expressions and is not sophisticated enough to avoid adding \r\n\ at the end of the content. What we will do is enhance the filter.

I am not sure whether we will be able to do so for the comingQ1 2009 SP1 to be released next week, because IE8 is the priority for this update - but in case we do not have the time, we will do so shortly after.

I am glad that for the time being you were able to resolve your issue using an SQL statement.

Sincerely yours,
Tervel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Informat
Top achievements
Rank 1
Answers by
Rumen
Telerik team
ManniAT
Top achievements
Rank 2
Tervel
Telerik team
Share this question
or