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

[Solved] Get reference to editor using MVC

1 Answer 124 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 26 Oct 2009, 05:31 AM
Hi,

I need to set some properties of the editor at run-time such as the SpellCheckSettings-DictionaryPath and the ImageManager-ViewPaths
However I am not sure how to get a reference to the serve control?

Using version 2009.1.311.35

I have tried

1) http://www.telerik.com/help/aspnet-ajax/editor_getingreferencetoradeditor.html   client side but this does not seem to work and I am not sure I can even set these properties using JavaScript?

2) Adding code behind class to reference it.

Code behind
protected void Page_Load(object sender, EventArgs e) 
        { 
            RadEditor1.ImageManager-ViewPaths= this.ViewData["imagePath"].ToString(); 
        } 

Controller
public ActionResult Index( ) 
        { 
            ViewData["imagePath"] = "~/Content/RadEditor/mypics/1";  
            return View("Index"); 
        } 

View
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs"  Inherits="mynamespave.Index"  %> 

When I do this the editor does not appear at all and I get the following JavaScript error:
Telerik.Web.UI.Editor is undefined 
 Telerik.Web.UI.Editor.CommandList... function(commandName, editor, args) {\r\n 
 
a is undefined 
Function.__typeName="Function";Function....Class("Sys.UI.Control",Sys.Component);\r\n

How do I set properties dynamically when using MVC?
Is their a new version MVC friendly version of the editor coming ?

Also

Why does this work
<
    RadEditor1.Content = (string)ViewData["Content"]"; 
%> 

but every other property appart from content seems not to work for example the below has no effect
<
    RadEditor1.EditModes = EditModes.Design; 
%> 



1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 28 Oct 2009, 03:57 PM
Hello Dave,

You can use server script tags to configure RadEditor, e.g.

<telerik:RadEditor ID="RadEditor1" DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd" runat="server">         
</telerik:RadEditor>
 
<script type="text/C#" runat="server">
    public void Page_Load(object sender, System.EventArgs e)
    {
        RadEditor1.EditModes = EditModes.Design;
        RadEditor1.ImageManager.ViewPaths = new string[]{ "~/Images"};
    }
</script>

For your convenience I have attached my test project.

Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Editor
Asked by
Dave
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or