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

Pb creating editor in codebehind

2 Answers 40 Views
Editor
This is a migrated thread and some comments may be shown as answers.
CSurieux
Top achievements
Rank 2
CSurieux asked on 28 Jul 2008, 07:02 AM
Hello,

Using build 2.723.35
I am unable to created editor in codebehind, I am using in may Page object:
        RadEditor ed ;  
        protected void Page_Load(object sender, EventArgs e)
        {
            if ( !IsPostBack )
                ed.Content="x";
        }
        protected override void OnInit(EventArgs e)
        {
           
            ed    =   new RadEditor();
          ed.ID           =   "RadEditorTextBox_1";
            Controls.Add(ed);
           
            base.OnInit(e);
        }

And I get an editor displayed but its window is bad formed and it doesn't accept input.
Adding one in the same page a declarative syntaxe like
    <telerik:RadEditor ID="RadEditor1" Runat="server">
        <Content></Content>
    </telerik:RadEditor>
works ??????

Any Idea ?

CS

2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 29 Jul 2008, 11:48 AM
Hello Christian,

To fix the problem you should add the editor's object to the Controls collection of the FORM, e.g.

form1.Controls.Add(ed);

Here is the whole code:

    RadEditor ed;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            ed.Content = "x";
    }
    protected override void OnInit(EventArgs e)
    {
        ed = new RadEditor();
        ed.ID = "RadEditorTextBox_1";
       
        form1.Controls.Add(ed);

        base.OnInit(e);
    }


Greetings,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CSurieux
Top achievements
Rank 2
answered on 29 Jul 2008, 12:52 PM
Hello Rumen,

Thanks for answer.
I don't understand why, but I succeded in instanciating the editor in a placeholder for my larger project just fixing a pb with a js file on my side...but the 'simple sample' where I directly add the placeholer to the Page does not works.

In my larger project the editor is not directly added to the Page Controls but to another control in this Collection, this must be the reason ?

I also solved my Skin Pb, so perfect.

Thanks.

CS
Tags
Editor
Asked by
CSurieux
Top achievements
Rank 2
Answers by
Rumen
Telerik team
CSurieux
Top achievements
Rank 2
Share this question
or