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

[Solved] How to load an instance from file

3 Answers 173 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 03 Dec 2007, 03:44 PM
We are dynamically creating RadEditors from code. Currently, I have code like this:

            RadEditor edt = new RadEditor ();
            edt.ID = "someid";
            edt.ToolbarMode = EditorToolbarMode.ShowOnFocus;
            edt.BorderStyle = BorderStyle.None;
            edt.ToolsFile = "Tools.xml";

Rather than hardcode these properties, I'd rather create new instances from file. My first thought was to use the XmlSerializer to load an instance from a persisted xml file - however, creating a new instance of XmlSerializer on RadEditor throws numerous exceptions.

Essentially, I want to do what .NET does when it encounters something like this in an ASPX page:
<telerik:RadEditor ID="RadEditor1" runat="server" EditModes="Design" Skin="WebBlue" ToolsFile="Tools.xml"  BorderStyle="None" ToolbarMode="ShowOnFocus">

that is, instantiate the control and set the properties based on markup.

Is there an easy way to do this?

3 Answers, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 05 Dec 2007, 03:10 PM
Hello Mark,

I would recommend the following approach:

Control editor2 = this.Page.ParseControl(  
                @"<%@ Register TagPrefix='telerik' Namespace='Telerik.Web.UI' Assembly='Telerik.Web.UI' %>
                <telerik:RadEditor ID='RadEditorDynamic' 
                runat='server' 
                EditModes='Design' 
                Skin='WebBlue' 
                ToolbarMode='ShowOnFocus'></telerik:RadEditor>");  
 
            this.Form.Controls.Add(editor2); 

One other option is to use an ASP.NET 2 Theme and a .skin file with various editor configurations.
Then all you need to do to configure the RadEditor Prometheus would be to set its SkinID property.

Regards,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Missing User
answered on 07 May 2008, 03:27 PM
I have followed your example using ParseControl to dynamically add a RadEditor control to my page. However, I want to use RadScriptManager instead of ScriptManager.

Is there a way to specify that in ParseControl?
0
Tervel
Telerik team
answered on 08 May 2008, 12:17 PM
Hello Cheri,

As you can see from the code provided, the ParseControl does not load a ScriptManager. Your ScriptManager declaration should already be at the page. And yes, you should be able to use a RadScriptManager instead.


Best regards,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
Mark
Top achievements
Rank 1
Answers by
Tervel
Telerik team
Missing User
Share this question
or