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

ModeChange event on Server side

4 Answers 55 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 21 Nov 2010, 06:49 PM

Hi, 
I am using a MOSSradEditor inside the following control hirarchy: 

Sharepoint Web part
- - - - Web user control
- - - - - - - - Rad Dock
- - - - - - - - - - - - MOSSRadEditor.

I would like to have ModeChange event of the MOSSRadEditor on the server side. For this purpose I handle the ClientModeChange event and then use RadAjaxManager to send the ajaxrequest to the server. But the method $find returns null in the line: 

 

var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");

 

 

Therefore I receive the javascript error Error: 'null' is null or not an object on the next line:        

 

ajaxManager.ajaxRequest(operation);

 

 

Can you pleae let me know how I can solve this problem, 
or proposing any pther way to have ModeChange event on the server side?
Here is the code section.

 

<%

 

@ Control Language="C#" AutoEventWireup="true" CodeBehind="EditFormUI.ascx.cs"

 

 

 

 

 

 

 

Inherits="EditingTools.Core.EditFormUI" %>

 

<%

 

@ Register Assembly="Telerik.Web.UI, Version=2010.2.826.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"

 

 

 

 

 

 

 

Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

<%

 

@ Register Assembly="RadEditorSharePoint, Version=5.8.1.0, Culture=neutral, PublicKeyToken=1f131a624888eeed"

 

 

 

 

 

 

 

Namespace="Telerik.SharePoint" TagPrefix="telerikSP" %>

 

 

 

 

<

 

 

asp:ScriptManager ID="ScriptManager1" runat="server">

 

</

 

 

asp:ScriptManager>

 

<

 

 

telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">

 

</

 

 

telerik:RadAjaxManager>

 

<

 

 

telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

 

 

 

 

 

 

 

<script type="text/javascript">

 

 

 

 

 

 

 

function ajaxRequest(operation) {

 

 

 

var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");

 

ajaxManager.ajaxRequest(operation);

}

 

 

</script>

 

</

 

 

telerik:RadScriptBlock>

 

<

 

 

telerik:RadDockLayout ID="RadDockLayout1" runat="server">

 

 

 

 

 

 

 

<telerik:RadDockZone ID="dockZone" runat="server" Orientation="Vertical" Width="100%"

 

 

 

 

 

 

 

FitDocks="true">

 

 

 

 

 

 

 

<telerik:RadDock ID="dockAma" runat="server" >

 

 

 

 

 

 

 

<ContentTemplate>

 

 

 

 

 

 

 

<telerikSP:MOSSRadEditor ID="EditorAma" runat="server" OnClientModeChange="Editor_ModeChange">

 

 

 

 

 

 

 

<Content>

 

 

 

 

 

 

 

</Content>

 

 

 

 

 

 

 

</telerikSP:MOSSRadEditor>

 

 

 

 

 

 

 

</ContentTemplate>

 

 

 

 

 

 

 

</telerik:RadDock>

 

 

 

 

 

 

 

</telerik:RadDockZone>

 

</

 

 

telerik:RadDockLayout>

 

 

 

 

 

<

 

 

script type="text/javascript">

 

 

 

 

 

RadEditorCommandList[

 

"Save"] = function (commandName, editor, oTool) {

 

ajaxRequest(

 

"Save" );

 

}

RadEditorCommandList[

 

"Cancel"] = function (commandName, editor, oTool) {

 

ajaxRequest(

 

"Cancel");

 

}

 

 

function Editor_ModeChange(editor, args) {

 

 

 

var mode = editor.get_mode();

 

 

 

switch (mode) {

 

 

 

case 1:

 

ajaxRequest(

 

"Design" );

 

 

 

break;

 

 

 

case 4:

 

ajaxRequest(

 

"Preview" );

 

}

}

 

 

 

</

 

 

script>

 

Thank you in advance.

 

 

 

4 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 25 Nov 2010, 12:40 PM
Hi Ali,

The approach that you have taken to handle ClientModeChange event is recommended one. I am to quite sure why the $find method returns null.

Could you try adding the RadAjaxManager directly to the WebPart's controls collection but not inside the UserControl and see if the problem still occurs?

Best wishes,
Dobromir
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Ali
Top achievements
Rank 1
answered on 08 Dec 2010, 01:56 PM
Hi, 
Now I have two solutions for this.
1. Adding RadAjaxManager directly to webparts control collection, as you mentioned in your response, and
2. Using 
var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>", document.parentWindow); 
instead of 
var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");

Both work. But now the problem is that Internet Explorer becomes very slow and displays the  message as in the attachment.
I appreciate it if you tell me how I can solve this problem.
Regards,
Ali
0
Dobromir
Telerik team
answered on 10 Dec 2010, 02:11 PM
Hi Ali,

One of the reasons for such error to occur is if there is a endless recursion in the scripts. Could you please provide more detailed information on the specific scenario? Do you update the RadEditor with the AjaxManager? If so, you should note that, when loaded RadEditor is set into EditMode and if you are changing the mode with JavaScript the OnClientMode event will be fired again, and this may lead to such recursion.

Greetings,
Dobromir
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Ali
Top achievements
Rank 1
answered on 03 Jan 2011, 11:11 AM
Hi, 
Thank you for your explanation. That was right. a recursion was occuring in my architecture.
Since I use MOSSRadEditor in Sharepoint environment, I needed to check out the source file where the editor contents come from, when the user clicks on Design. If the checkout was successful on the server, then I used set_mode() function to allow the editor to enter design mode.
With your explanations, I noticed that I need to do some revisions in the overall architecture. Now check-in / check-out operations are done through toolbar buttons, rather than design and preview buttons.

Best regards,
Ali
Tags
Editor
Asked by
Ali
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Ali
Top achievements
Rank 1
Share this question
or