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

Using RadEditor in custom MOSS solutions

8 Answers 202 Views
Sharepoint Integration
This is a migrated thread and some comments may be shown as answers.
Gian-Franco Salvato
Top achievements
Rank 1
Gian-Franco Salvato asked on 17 Oct 2007, 02:23 PM
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

8 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 17 Oct 2007, 04:14 PM
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
0
Gian-Franco Salvato
Top achievements
Rank 1
answered on 18 Oct 2007, 12:02 PM
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
0
Gian-Franco Salvato
Top achievements
Rank 1
answered on 19 Oct 2007, 07:35 AM
hi
somebody who has an answer for me???

regards tom
0
Lini
Telerik team
answered on 19 Oct 2007, 04:17 PM
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
0
Gian-Franco Salvato
Top achievements
Rank 1
answered on 23 Oct 2007, 09:37 AM
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

0
Lini
Telerik team
answered on 24 Oct 2007, 08:17 AM
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
0
Gian-Franco Salvato
Top achievements
Rank 1
answered on 24 Oct 2007, 09:23 AM
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
0
Lini
Telerik team
answered on 25 Oct 2007, 04:21 PM
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
Tags
Sharepoint Integration
Asked by
Gian-Franco Salvato
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Gian-Franco Salvato
Top achievements
Rank 1
Lini
Telerik team
Share this question
or