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

Validations done for RadEditor

3 Answers 61 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Sups
Top achievements
Rank 1
Sups asked on 19 Nov 2009, 09:25 PM
Hello

we are using telerik version "2008.2.826.20" radeditor for one of my project.
It works normal for some of the html fomats. But sometimes there are senarios where on pasting some html in html mode, switch to design mode and then again when tried to switch to Html mode it gives javascript error

Message: 'styleSheet' is null or not an object
Line: 461
Char: 1
Code: 0
URI: http://............/ScriptResource.axd?d=llZhXWl6Cygg2gNOHRv3hQfS9_g_NzcOyPqP5JZNQHJND-oOwSYEBW9js92K5CCKKYPSxJECyJQOoHQRmadliQ2&t=633731249133424980

We tried copying same html in latest radeditor of telerik's site but iwe get same error.
We also tried disabling ConvertToXHtml content filter but that didnt help.

Here is one of the kind of html which we try to paste:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<html><head>
<meta http-equiv="content-language" content="en-us">
<title>Company</title>
</head>
<body >
<div class="mktEditable" id="main_text" ><br>Hello {{First Name:default=Sir/Madam}},<br> <mce:Style><mce:Style> <br>
This is for testing.
<div>
</body>
</html>

When I remove this "<mce:Style><mce:Style>" tag from the html, it works fine.

Can anyone tell me what could be the issue for this? What setting I have to do for getting rid of this?
We aslo want to know whether validation while switching between modes and submitting can be disabled. As stated we tried disabling contentfilters but no use. Tried ContentFilters = "None" also.

Please reply ASAP as this was the complaint from our Clients.

Thanks in advance.
Sups

3 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 24 Nov 2009, 07:56 AM
Hi Sups,

You are using custom tags with xml:namespaces, which as you know need to be closed, because XML is a strict language. Yours do not seem closed (neither self-closing, nor with a closing tag), and this is why you get the JavaScript error. If you try to close them with either approach you will not experience the error anymore, but, please, have in mid the fact that RadEditor is a rich text editor, not an XML or a code editor at all.

Sincerely yours,
Martin Ivanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sups
Top achievements
Rank 1
answered on 24 Nov 2009, 03:42 PM
Hi Martin,

Thanks for you quick reply.

I did as suggested and it worked. But my main concern is how to ignore such type of tags rather than getting such javascript errors.
If such tags are there then just remove those and display rest of the content.

These kind of contents are added/uploaded by clients. We can't tell them to be specific with what they enter/upload. We have to handle the errors and let them move ahead.

Please can you suggest something on this, it would be of great help.

Thanks,
Sups
0
Rumen
Telerik team
answered on 27 Nov 2009, 11:50 AM
Hi Sups,

You can check all pasted tags in the OnClientPasteHtml event of RadEditor which is fired when the onpaste event of the browser is executed, e.g.

<script type="text/javascript">
function OnClientPasteHtml(sender, args)
{
    var commandName = args.get_commandName();
    var value = args.get_value();
    
    if (commandName == "Paste")
    {
       //strip the unwanted tags here and set the new content
        args.set_value(value);  //set the modified pasted content in the editor
    }
}
</script>
<telerik:radeditor runat="server" ID="RadEditor1" OnClientPasteHtml="OnClientPasteHtml"></telerik:radeditor>

Since you should implement regular expressions that strip the unwanted tags you can find the information in this forum thread useful: Any comments/suggestions for this HTML tag-stripping filter?.

Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Editor
Asked by
Sups
Top achievements
Rank 1
Answers by
Martin
Telerik team
Sups
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or