Using RadEditor in custom MOSS solutions

9 posts, 0 answers
  1. Gian-Franco Salvato
    Gian-Franco Salvato avatar
    11 posts
    Member since:
    Dec 2006

    Posted 17 Oct 2007 Link to this post

    hi there

    i tried to use the radeditor in my own written moss 2007 webpart.
    used the documentation (RadEditorMOSS_4_4.chm) of the newest (trial) release, i  always get an error while loading the webpart.

    stack trace:
    -------------
    [MethodAccessException: Telerik.SharePoint.MOSSRadEditor..ctor()] company.MOSS.WebParts.Content2Cols.CreateChildControls() +0 System.Web.UI.Control.EnsureChildControls() +87 System.Web.UI.Control.PreRenderRecursiveInternal() +41 System.Web.UI.WebControls.WebParts.WebPart.PreRenderRecursiveInternal() +62 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
    --------
    any hints?

    thx tom
  2. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 17 Oct 2007 Link to this post

    Hi Tom,

    Please, make sure that you are using the Trial or the paid version of RadEditor for MOSS 2007 (you need this version RadEditor_MOSS_4_4_0_dev.zip available in the My Licenses -> My Purchases -> RadEditor for ASP.NET -> Downloads section).

    Regarding the error message, we assume that you are using the free version which does not offer the requested functionality.


    Best regards,
    Rumen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  3. Gian-Franco Salvato
    Gian-Franco Salvato avatar
    11 posts
    Member since:
    Dec 2006

    Posted 18 Oct 2007 Link to this post

    hi rumen

    this works fine in your way - thx.
    but now still the problem while loading site:
    ---
    exception while executing client event onclientload
    error: radeditorclientload is undefined
    ---
    used following code in the webpart:
    ---
    contentEditor = new MOSSRadEditor();
    contentEditor.Content = "Enter content here...";
    contentEditor.Editable = true;
    contentEditor.EnableViewState = true;
    contentEditor.ID = "radEdit"+this.ID;
    contentEditor.RadControlsDir = "~/_wpresources/RadEditorSharepoint/4.4.0.0__1f131a624888eeed/RadControls/";
    this.Controls.Add(contentEditor);
    contentEditor.RenderControl(writer);
    ---
    do u see something what is wrong in my code fragment or waht is missing for init the rad editor on client side?

    thx for answer, asap.
    kind regards
    tom
  4. Gian-Franco Salvato
    Gian-Franco Salvato avatar
    11 posts
    Member since:
    Dec 2006

    Posted 19 Oct 2007 Link to this post

    hi
    somebody who has an answer for me???

    regards tom
  5. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 19 Oct 2007 Link to this post

    Hello Tom,

    I think that creating the editor in the Render method is a bit too late in the control lifecycle. Some of the editor scripts need to be placed at the beginning of the page, so if you create it at this stage they will not be outputed. That is why you get a client exception.

    I recommend that you create the editor in the CreateChildControls method instead. For example:

    ...
    MOSSRadEditor contentEditor;

    protected override void CreateChildControls()
    {
        
    base.CreateChildControls();
        

        contentEditor =
    new MOSSRadEditor();
        contentEditor.Content =
    "Enter content here...";
        contentEditor.ID =
    "radEdit" + this.ID;
        
    this.Controls.Add(contentEditor);
    }


    ...

    protected override void Render(HtmlTextWriter writer)
    {
        EnsureChildControls(); 
        
    base.Render(writer);
    }


    Regards,
    Lini
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Gian-Franco Salvato
    Gian-Franco Salvato avatar
    11 posts
    Member since:
    Dec 2006

    Posted 23 Oct 2007 Link to this post

    hi all

    that works fine in this way - cool...!

    now last question:
    ---------------------
    i use the rad editor to edit a field defined in the webpart.
    write actual content into the editor an modify is very easy.
    but how can i write back the modified content in rad editor into the webpart field?
    is there a event i can use it for save back?

    thx a lot
    tom

  7. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 24 Oct 2007 Link to this post

    Hi Tom,

    You can create a simple string property for the web part and store it in the web part storage. For example:

    private string _text = "";

    [Browsable(false)]
    [WebPartStorage(Storage.Personal)]
    [
    FriendlyName("EditorContent")]
    [
    Description("EditorContentProperty")]
    public virtual string EditorContent
    {
        get { return _editorContent; }
        set { _editorContent = value; }
    }

    Then get and set the content in the editor from this property.

    Best wishes,
    Lini
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Gian-Franco Salvato
    Gian-Franco Salvato avatar
    11 posts
    Member since:
    Dec 2006

    Posted 24 Oct 2007 Link to this post

    hi all
    this with string property is clear. i use it like this:
    -----------
    protected override void CreateChildControls()
    {
        base.CreateChildControls();
         //check mode
        this.contentEditorLeft = new MOSSRadEditor();
        this.contentEditorLeft.Content = this.ColumnLeft;
        ...
    -----------
    but how is the way back - from editor to webpart field?
    something like:
    -----------
    //write into webpart field
    this.ColumnLeft = this.contentEditorLeft.Content;
    ...
    -----------
    when i have to write into the webpart property when i save or publish the page? is there an event to use or so?

    thanx a lot

    regards
    tom
  9. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 25 Oct 2007 Link to this post

    Hi Tom,

    If the editor will be available after you submit the page (e.g. after you click OK or Apply in the web part menu) then you can enable its ViewState and get the value from the control itself - i.e. contentEditorLeft.Content.
    If the editor will be hidden after you submit the page (e.g. you want to hide the editor after you click OK or Apply), then you need to save its content into another container - for example a hidden textbox. To do this you will need to write a bit of JavaScript and attach to the RADEVENT_SUBMIT (http://www.telerik.com/help/aspnet/Editor/?AttachEventHandler.html) client editor event:

    editor.AttachEventHandler ("RADEVENT_SUBMIT", function (){....});

    This way you will be able to get the content right before the page postback.

    All the best,
    Lini
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top