Pb creating editor in codebehind

3 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 28 Jul 2008 Link to this post

    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. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 29 Jul 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 29 Jul 2008 Link to this post

    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
Back to Top