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

InsertParagraph inserts div tag when NewLineMode=DIV

4 Answers 167 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 2
Dennis asked on 04 Oct 2016, 10:54 PM

In the RadEditor we have the NewLineMode set to Div...

Me.NewLineMode = EditorNewLineModes.Div

We are also using a ToolsFile xml document to control the tools available in RadEditor.

The problem is the InsertParagraph tool now inserts <div> tags instead of <p> tags.

We want to keep the NewLineMode behavior as DIV while still having a tool that can insert a paragraph (i.e. a <p> tag).

How can we do this?

 

4 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Oct 2016, 08:52 AM
Hi,

Are you sure that the InsertParagraph command inserts a div tag when the NewLineMode is set to DIV? Am I asking because I am unable to reproduce this behavior when I switch the NewLineMode to DIV in the live demo -> the InsertParagraph tool is inserting a paragraph.

Nevertheless, if you'd like you can overwrite the command using the following code as a base:

<script type="text/javascript">
function OnClientCommandExecuting(editor, args)
{
    if("InsertParagraph" == args.get_commandName())
    {
        editor.pasteHtml("<p> </p>");
        args.set_cancel(true);
    }
}
</script>
<telerik:radeditor runat="server" ID="RadEditor1" NewLineMode="Div" OnClientCommandExecuting="OnClientCommandExecuting"></telerik:radeditor>



Regards,
Rumen
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Dennis
Top achievements
Rank 2
answered on 05 Oct 2016, 02:52 PM

In the RadEditor demo, first set "NEW LINES AS" to "Divs".

Then, in the editor content area just above the "Destinations" table, Type in three lines:

Comment1

Comment2

Comment3

If you then toggle to the HTML tab, you will see that the Comment1 line is (incorrectly) bracketed by a <p> tag while the Comment2 and Comment3 lines are (correctly) bracketed by <div> tags.

Next, go back to the Design tab and position yourself at the beginning of the Comment3 line then click the [Insert Paragraph] button.

In the newly inserted "paragraph" type "Comment2b".

If you then toggle to the HTML tab you will see that Comment2b is incorrectly bracketed by a <div> tag.

 

Regarding your suggested solution, in our application we have created an inherited control for the RadEditor so that we have consistent behavior throughout our application without having to set the attributes for each individual RadEditor instance in markup or Javascript. 

How would I accomplish your Javascript example in code-behind using VB.NET?

Dennis

0
Rumen
Telerik team
answered on 07 Oct 2016, 08:42 AM
Hello,

Thank you for the bug report.Can you please log it in our public feedback portal?

As to the workaround, you can see how to execute script code through the codebehind in the following pages:
http://stackoverflow.com/questions/9235017/asp-net-vb-call-javascript-function-from-code-behind
http://stackoverflow.com/questions/7673795/call-javascript-from-vb-net-code-behind
http://www.devcurry.com/2009/01/execute-javascript-function-from-aspnet.html

This is needed because the InsertParagraph tool is a client-side functionality that is executed in the browser and it is not possible to be controlled on the server.

Best regards,
Rumen
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Rumen
Telerik team
answered on 10 Oct 2016, 07:57 AM
Hi there,

For reference I'd like to post here your bug report https://feedback.telerik.com/Project/108/Feedback/Details/203023-new-post-in-insertparagraph-inserts-div-tag-when-newlinemode-div-and-should-inser and add that your Telerik points have been updated.

Best regards,
Rumen
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Editor
Asked by
Dennis
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Dennis
Top achievements
Rank 2
Share this question
or