Hello,
I need to add the Editor to the page programmatically. When I do, I end up missing about a dozen scripts that I would normally see when the editor is inline in the aspx. Because of the missing scripts, I get "Telerik is not defined."
Here's how I'm adding the control. Can you tell me what else I should be doing?
Thanks,
Jeff
I need to add the Editor to the page programmatically. When I do, I end up missing about a dozen scripts that I would normally see when the editor is inline in the aspx. Because of the missing scripts, I get "Telerik is not defined."
Here's how I'm adding the control. Can you tell me what else I should be doing?
Thanks,
Jeff
| protected void Page_Load(object sender, EventArgs e) |
| { |
| // "Content" is a ContentPlaceHolder in a master page |
| Content.Controls.Add(InitializeEditor()); |
| // Add inline scripts for handling commands. etc. |
| RegisterScripts(); |
| // Contains 'EditorLoaded' function, filters, etc. |
| litEditorScript.Text = |
| string.Format("<script src=\"{0}{1}\" type=\"text/javascript\"></script>", |
| URLs.RootPath, "js/ControlsEditMode.js"); |
| } |
| private RadEditor InitializeEditor() |
| { |
| RadEditor re = new RadEditor(); |
| re.ContentFilters = EditorFilters.RemoveScripts | EditorFilters.FixEnclosingP | EditorFilters.FixUlBoldItalic | |
| EditorFilters.MozEmStrong | EditorFilters.ConvertFontToSpan | EditorFilters.ConvertFontToSpan | |
| EditorFilters.IndentHTMLContent; |
| re.ContentAreaCssFile = "~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"; |
| re.ToolsFile = "~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"; |
| re.Skin = "Office2007"; |
| re.NewLineBr = false; |
| re.OnClientPasteHtml = "OnClientPasteHtml"; |
| re.OnClientLoad = "EditorLoaded"; |
| //Css, Font, MSWordRemoveAll |
| re.StripFormattingOptions = EditorStripFormattingOptions.Css | EditorStripFormattingOptions.Font | |
| EditorStripFormattingOptions.MSWordRemoveAll; |
| re.CssFiles.Add("~/style.css"); |
| re.CssFiles.Add("~/designer.css"); |
| re.FlashManager.DeletePaths = new string[] { "~/Files" }; |
| re.FlashManager.UploadPaths = new string[] { "~/Files" }; |
| re.FlashManager.ViewPaths = new string[] { "~/Files" }; |
| re.ImageManager.DeletePaths = new string[] { "~/Images" }; |
| re.ImageManager.UploadPaths = new string[] { "~/Images" }; |
| re.ImageManager.ViewPaths = new string[] { "~/Images" }; |
| re.DocumentManager.DeletePaths = new string[] { "~/Files" }; |
| re.DocumentManager.UploadPaths = new string[] { "~/Files" }; |
| re.DocumentManager.ViewPaths = new string[] { "~/Files" }; |
| re.MediaManager.DeletePaths = new string[] { "~/Files" }; |
| re.MediaManager.UploadPaths = new string[] { "~/Files" }; |
| re.MediaManager.ViewPaths = new string[] { "~/Files" }; |
| return re; |
| } |
| private void RegisterScripts() |
| { |
| Type cstype = GetType(); |
| ClientScriptManager cs = Page.ClientScript; |
| string strPageEditorInline = HttpContext.Current.Server.MapPath(URLs.RootPath + "Sitefinity/Admin/Scripts/PageEditorInline.js"); |
| // Check to see if the client script is already registered. |
| if (!cs.IsClientScriptBlockRegistered(cstype, "PageEditorInline") && |
| File.Exists(strPageEditorInline)) |
| cs.RegisterClientScriptBlock(cstype, "PageEditorInline", |
| File.ReadAllText(strPageEditorInline), true); |
| } |
