Problem Creating Ajax Custom Editor (Telerik)

Topics: User Forum
Feb 10, 2009 at 3:22 AM
I am trying to create a custom editor that employs Telerik's RadEditor, but I get an error: The control with ID 'ctl01' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.  when I try to create a page with it.


The editor class (showing only AddEditor) :

public class RadHTMLContentAttribute : N2.Details.AbstractEditableAttribute
{     
    
protected override Control AddEditor(Control container) 
    {
        
Telerik.Web.UI.RadEditor redit = new Telerik.Web.UI.RadEditor(); 
        
container.Controls.Add(redit);
        
return redit;
    }
}


The Item:

using System.Collections.Generic;
using System.Linq;
using System.Web;
using N2;

namespace MyProject.Items
{
    [
Definition("JC Page")] 
    
public class JCBasePagePage : N2.ContentItem 
    
{
        
public override string TemplateUrl  {get { return "~/UI/JCBasePage.aspx"; } }

        [
RadHTMLContentAttribute
        
public virtual string RadText 
        {
            
get {return (string)(GetDetail("RadText")); }
            
set {SetDetail("RadText", value); }
        }
    }
}

The template aspx has a ScriptManager on it.

here is the template code-behind:

namespace
MyProject.UI
{
    
public partial class JCBasePage : MyProject.Items.JCBasePagePage 
    
{
        
protected void Page_Load(object sender, EventArgs e) {}
    }
}


The more I learn about N2, the more I like it.  I hope what I want to do is possible.

 

 

 

Coordinator
Feb 10, 2009 at 6:25 AM
Have you tried adding an <asp:ScriptManager to JCBasePage.aspx?
Feb 10, 2009 at 1:06 PM

Sorry, I wasn't very clear on that, but yes.  

I am very new to N2, so the problem could be that I don't know what I am doing ;) 

Coordinator
Feb 10, 2009 at 4:43 PM
Ahh, I see. The exception is thrown when editing the page.  How about adding a container.Controls.Add(new ScriptManager()) just before adding the RadEditor.

What do you think of the RadEditor by the way. It just came up as an alternative for another project and I'm curious what you think about it.
Feb 10, 2009 at 5:02 PM
adding the script to the editor yields another problem:  Script controls may not be registered before PreRender 

protected
override Control AddEditor(Control container)
{

    
ScriptManager sm = new ScriptManager();
    container.Controls.Add(sm);

    // add the editor
    Telerik.Web.UI.RadEditor redit = new Telerik.Web.UI.RadEditor();
    redit.Content =
"";
    container.Controls.Add(redit);
    return redit;
}

 

Coordinator
Feb 10, 2009 at 6:57 PM
After reading this clue perhaps adding the scriptmanager to the form might do the trick.

    container.Page.Form.Controls.Add(sm);

Might possibly be related to .NET version. You could try to add the scriptmanager to edit.aspx
Feb 11, 2009 at 12:59 AM
Libardo,

Thank you for your time.  It is greatly appreciated!

Adding the script manager to the form yields this error: The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.

...but adding the ScriptManger to edit.aspx (Framed.master) resolved that issue.

Now I can see the editor, but after I save the new page (of type "JC Page"), I get this error:

 'MyProject.UI.JCBasePage' is not allowed here because it does not extend class 'System.Web.UI.Page'.


The item, "JC Page" derrives from N2.ContentItem - is that not correct?
Coordinator
Feb 11, 2009 at 9:14 PM
Looks like you might be consusing the page templates (aspx) with the item definition (derives from n2.contentitem).

Try changing into this:

namespace MyProject.UI
{
    
public partial class JCBasePage : N2.Web.UI.ContentPage<MyProject.Items.JCBasePagePage>
    
{
        
protected void Page_Load(object sender, EventArgs e) {}
    }
}

Feb 14, 2009 at 1:47 AM
Thanks libardo, that was it.
Jul 8, 2009 at 1:31 PM

I have the same problem when creating custom editor from RadDateTimePicker. I followed this instructions, but still getting error script messages like "Type.registerNamespace("Telerik.Web.UI");" is undefined. When building the editor i added all required scripts for the RadDateTime picker but the problem remains.

 <font size="2">

 

</font>

private void AddDatePickerScript(Control container)

{

 

<font size="2">

container.Page.ClientScript.RegisterClientScriptInclude(

</font>

"Core",<font size="2">

container.ResolveUrl(

</font>

"~/Secure/UI/Scripts/Core.js"));

 

<font size="2">

container.Page.ClientScript.RegisterClientScriptInclude(

</font>

"RadInputScript",<font size="2">

container.ResolveUrl(

</font>

"~/Secure/UI/Scripts/RadInputScript.js"));<font size="2">

container.Page.ClientScript.RegisterClientScriptInclude(

</font>

"RadDateInputScript",<font size="2">

container.ResolveUrl(

</font>

"~/Secure/UI/Scripts/RadDateInputScript.js"));<font size="2">

container.Page.ClientScript.RegisterClientScriptInclude(

</font>

"RadCalendarCommonScript",<font size="2">

container.ResolveUrl(

</font>

"~/Secure/UI/Scripts/RadCalendarCommonScript.js"));

 

<font size="2">

container.Page.ClientScript.RegisterClientScriptInclude(

</font>

"RadDatePicker",<font size="2">

container.ResolveUrl(

</font>

"~/Secure/UI/Scripts/RadDatePicker.js"));

 

<font size="2">

container.Page.ClientScript.RegisterClientScriptInclude(

</font>

"RadDateTimePickerScript",<font size="2">

container.ResolveUrl(

</font>

"~/Secure/UI/Scripts/RadDateTimePickerScript.js"));

 

<font size="2">

container.Page.ClientScript.RegisterClientScriptInclude(

</font>

"RadDateTimePickerScript",<font size="2">

container.ResolveUrl(

</font>

"~/Secure/UI/Scripts/RadDateTimePickerScript.js"));

}

 Any ideas?

Coordinator
Jul 8, 2009 at 7:32 PM

Your message has a very strange formatting, could you try posting again? Also, which of the instructions did you follow?