Im has decided to try to integrate Editor in CommunityServer 2007, after read
thread
http://www.telerik.com/community/forums/thread/b311D-mdmhe.aspx
and having looked sources of wrapper I on tried to make this too
most for Editor from "Prometheus" project. The first with what was the
problem: it "System. InvalidOperationException: The control with ID '
Editor ' requires a ScriptManager on the page. The ScriptManager must
appear before any controls that need it. ".
For the decision of a problem it was necessary to write wrapper which
creates inside of itself instance Editor, configures it, and then creates
instance ScriptManager and adds in wrapper collection of controls all over
again a instance of ScriptManager, and then a instance of Editor, code of wrapper:
after that, im add to code check for add ScriptManager to the page once (valiable smAdded), this is a bad workaround :(.
At now Editor display at page, but not functional, and im take some JavaScript errors in Firefox:
Error: InlineContentEditor is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Sys is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_Modal is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_InlineEditor is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: DefaultTextEditor is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_DblClickInlineEditorPanel is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_DblClickInlineEditorPanel is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: TagEditor is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Sys is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_TabbedPanes is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
If you have an opportunity, please help, to understand with a problem.
Probably someone already faced the same problem and could solve it.
Thankful in advance for the help!
thread
http://www.telerik.com/community/forums/thread/b311D-mdmhe.aspx
and having looked sources of wrapper I on tried to make this too
most for Editor from "Prometheus" project. The first with what was the
problem: it "System. InvalidOperationException: The control with ID '
Editor ' requires a ScriptManager on the page. The ScriptManager must
appear before any controls that need it. ".
For the decision of a problem it was necessary to write wrapper which
creates inside of itself instance Editor, configures it, and then creates
instance ScriptManager and adds in wrapper collection of controls all over
again a instance of ScriptManager, and then a instance of Editor, code of wrapper:
public class RadEditorWrapper : WebControl, ITextEditor, ITextControl |
{ |
private Dictionary<string, string> configOptions = new Dictionary<string, string>(); |
private bool _enableHtmlModeEditing = true; |
private static bool smAdded = false; |
private RadEditor editor; |
private ScriptManager scriptManager; |
#region ITextEditor Members |
public void ApplyConfigurationOption(string name, string value) |
{ |
//Save config options |
if (configOptions.ContainsKey(name)) |
configOptions[name] = value; |
else |
configOptions.Add(name, value); |
//Try to set control properties |
Type t = editor.GetType(); |
System.Reflection.PropertyInfo pi = t.GetProperty(name); |
if (pi != null) |
{ |
if (pi.PropertyType == typeof(string)) |
{ |
pi.SetValue(editor, value, null); |
} |
else if (pi.PropertyType == typeof(int)) |
{ |
pi.SetValue(editor, int.Parse(value), null); |
} |
} |
} |
public int Columns |
{ |
get |
{ |
return 80; |
} |
set |
{ |
} |
} |
public bool EnableHtmlModeEditing |
{ |
get |
{ |
return this._enableHtmlModeEditing; |
} |
set |
{ |
this._enableHtmlModeEditing = value; |
} |
} |
public string GetBookmarkScript() |
{ |
return ""; |
} |
public string GetContentInsertScript(string contentVariableName) |
{ |
return string.Format("$find(\"<%={1}%>\").pasteHtml('{0}');", contentVariableName, this.ClientID); |
} |
public string GetContentScript() |
{ |
return string.Format("$find(\"<%={0}%>\").get_Html(true);", this.ClientID); |
} |
public string GetContentUpdateScript(string contentVariableName) |
{ |
return string.Format("$find(\"<%={1}%>\").set_Html('{0}');", contentVariableName, this.ClientID); |
} |
public string GetFocusScript() |
{ |
return string.Format("$find(\"<%={0}%>\").setFocus();", this.ClientID); |
} |
public bool IsSupported(System.Web.HttpBrowserCapabilities browser) |
{ |
return true; |
} |
public bool IsRichTextCapable |
{ |
get { return true; } |
} |
public int Rows |
{ |
get |
{ |
return 20; |
} |
set |
{ |
} |
} |
#endregion |
#region ITextControl Members |
public string Text |
{ |
get |
{ |
return editor != null ? editor.Content : string.Empty; |
} |
set |
{ |
if (editor != null) |
editor.Content = value; |
} |
} |
#endregion |
public RadEditorWrapper() |
{ |
editor = CreateRadEditor(); |
editor.ID = "RadEditor"; |
scriptManager = new ScriptManager(); |
scriptManager.EnablePartialRendering = true; |
scriptManager.ID = "RadEditorScriptManager"; |
} |
protected override void CreateChildControls() |
{ |
if (!smAdded) |
{ |
this.Controls.Add(scriptManager); |
smAdded = true; |
} |
this.Controls.Add(editor); |
} |
protected override void OnUnload(EventArgs e) |
{ |
smAdded = false; |
base.OnUnload(e); |
} |
private RadEditor CreateRadEditor() |
{ |
RadEditor editor = new RadEditor(); |
editor.Modules.Clear(); |
//DialogDefinition insertEmoticonDialogDefinition = new DialogDefinition("~/EmoticonsDialog.ascx", new DialogParameters()); |
//insertEmoticonDialogDefinition.Modal = true; |
//insertEmoticonDialogDefinition.VisibleTitlebar = true; |
//insertEmoticonDialogDefinition.VisibleStatusbar = false; |
//insertEmoticonDialogDefinition.Width = Unit.Pixel(250); |
//insertEmoticonDialogDefinition.Height = Unit.Pixel(250); |
//editor.AddDialogDefinition("Emoticons", insertEmoticonDialogDefinition); |
InitToolbar(editor); |
SetImageManagerProps(editor); |
return editor; |
} |
private void SetImageManagerProps(RadEditor editor) |
{ |
string baseVirtualPath = "~/UserImages"; |
string cuurentUserName = CurrentUserName.LastIndexOf('\\') < 0 ? CurrentUserName : CurrentUserName.Substring(CurrentUserName.LastIndexOf('\\') + 1); |
if (!IsMember) |
return; |
string basePath = HttpContext.Current.Server.MapPath(baseVirtualPath); |
string userPath = string.Format("{0}\\{1}", basePath, cuurentUserName); |
string userVirtualPath = string.Format("{0}/{1}", baseVirtualPath, cuurentUserName); |
if (!Directory.Exists(basePath)) |
Directory.CreateDirectory(basePath); |
if (!Directory.Exists(userPath)) |
Directory.CreateDirectory(userPath); |
editor.ImageManager.UploadPaths = new string[] { userVirtualPath }; |
editor.ImageManager.ViewPaths = new string[] { userVirtualPath }; |
editor.ImageManager.MaxUploadFileSize = 5242880; // 5 Mb |
} |
private void InitToolbar(RadEditor editor) |
{ |
EditorToolGroup group = new EditorToolGroup(); |
group.Tools.Add(new EditorTool("Bold")); |
group.Tools.Add(new EditorTool("Underline")); |
group.Tools.Add(new EditorTool("Italic")); |
group.Tools.Add(new EditorSeparator()); |
group.Tools.Add(new EditorTool("JustifyLeft")); |
group.Tools.Add(new EditorTool("JustifyCenter")); |
group.Tools.Add(new EditorTool("JustifyRight")); |
group.Tools.Add(new EditorTool("JustifyFull")); |
group.Tools.Add(new EditorTool("JustifyNone")); |
group.Tools.Add(new EditorSeparator()); |
group.Tools.Add(new EditorTool("ForeColor")); |
group.Tools.Add(new EditorTool("BackColor")); |
group.Tools.Add(new EditorSeparator()); |
if (IsMember) |
{ |
group.Tools.Add(new EditorTool("ImageManager")); |
group.Tools.Add(new EditorSeparator()); |
} |
group.Tools.Add(new EditorTool("InsertOrderedList")); |
group.Tools.Add(new EditorTool("InsertUnorderedList")); |
group.Tools.Add(new EditorTool("InsertSymbol")); |
group.Tools.Add(new EditorTool("InsertHorizontalRule")); |
group.Tools.Add(new EditorSeparator()); |
group.Tools.Add(new EditorTool("LinkManager")); |
group.Tools.Add(new EditorTool("Unlink")); |
group.Tools.Add(new EditorSeparator()); |
group.Tools.Add(new EditorTool("AjaxSpellCheck")); |
//EditorTool emoticons = new EditorTool("Emoticons"); |
//emoticons.ShowIcon = true; |
//group.Tools.Add(emoticons); |
editor.Tools.Clear(); |
editor.Tools.Add(group); |
} |
private bool IsMember |
{ |
get |
{ |
return true; |
//return Roles.IsUserInRole("Members"); |
} |
} |
private string CurrentUserName |
{ |
get { return HttpContext.Current.User.Identity.Name; } |
} |
} |
after that, im add to code check for add ScriptManager to the page once (valiable smAdded), this is a bad workaround :(.
At now Editor display at page, but not functional, and im take some JavaScript errors in Firefox:
Error: InlineContentEditor is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Sys is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_Modal is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_InlineEditor is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: DefaultTextEditor is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_DblClickInlineEditorPanel is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_DblClickInlineEditorPanel is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: TagEditor is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Sys is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
Error: Telligent_TabbedPanes is not defined
http://localhost/cs/forums/AddPost.aspx?ForumID=1
If you have an opportunity, please help, to understand with a problem.
Probably someone already faced the same problem and could solve it.
Thankful in advance for the help!