'; editCommentDiv += '
'; editCommentDiv += ' '; editCommentDiv += '
'; editCommentDiv += ' '; editCommentDiv += '
'; editCommentDiv += '

Adding RadEditor using javascrpt:getting unterminated string literal error

244 Views Asked by At
var editCommentDiv = '<div id="divTicketCommentHistoryEditor">';
editCommentDiv += '<br />';
editCommentDiv += '<telerik:RadEditor ID="editorCommentsHistory" runat="server" EditModes="Design" ToolbarMode="ShowOnFocus" ToolsWidth="170px" Width="412px" Height="72px"></telerik:RadEditor>';

editCommentDiv += '<div>';
editCommentDiv += '<input id="cbEditIsPrivate" type="checkbox" />Make Comment/Note Private';
editCommentDiv += '&nbsp;';
editCommentDiv += '<a href="javascript:void(0)" onclick="return editCommentSave();">Update</a>';
editCommentDiv += '<a href="javascript:void(0)" onclick="return editCommentCancel();">Cancel</a>';
editCommentDiv += '</div></div>';

I'm getting unterminated string literal here

<telerik:RadEditor ID="editorCommentsHistory" runat="server" EditModes="Design" ToolbarMode="ShowOnFocus" ToolsWidth="170px" Width="412px" Height="72px"></telerik:RadEditor>' 
2

There are 2 best solutions below

0
user3792804 On BEST ANSWER
    public string editor(){
           RadEditor editor = new RadEditor();
            editor.ID = "radeditor";
//provide all the properties and toolbar options
            StringWriter sw = new StringWriter();
            HtmlTextWriter htWriter =new HtmlTextWriter(sw);
            editor.RegisterWithScriptManager = false;
            this.Controls.Add(editor);
            editor.RenderControl(htWriter);

            string strRenderedHTML = sw.ToString();
            return strRenderedHTML;
    }

finally stored the returned string in a hidden field (contains all html of Radeditor)and get value in .aspx page.

editCommentDiv += hiddenfield.value..

0
Rumen Jekov On

RadEditor for ASP.NET AJAX is a server control and it cannot be created on the client.

You need to put it on the page declaratively () or create it in the code behind and add it to the controls collection of another control. This is required because all the HTML code for the control (toolbars, skin CSS, etc.) is rendered and sent by the sever.