Dynamic content inline in editor

Vote:
 

I've made a dynamic content control using the DynamicContentPlugIn attribute. I have one control for edit as well as the control used for rendering the content. It works well as long as all I want is for the dynamic content placeholder to render as a block element in the editor, but it won't render inline. I've tried to implement IDynamicContentDisplayType in both my controls but RenderAsBlockElement is never called in either of them. Is there something I'm missing?

[DynamicContentPlugIn(
        DisplayName = "Name",
        Url = "EditControl.ascx",
        ViewUrl = "Control.ascx")]
public partial class MyClass: UserControl, IDynamicContentDisplayType
{
    /*Code here*/

    public bool RenderAsBlockElement { get { return false; } }
}

public partial class MyClassEdit : DynamicContentEditControl, IDynamicContentDisplayType
{
    public override void PrepareForSave()
    {
        Content.Properties[ "SelectedValue" ].Value = SelectedValue;
    }

    public bool RenderAsBlockElement { get { return false; } }
}

#58488
Apr 26, 2012 15:45
Vote:
 

Hi!


Just by browsing the code quickly I see that we internally handle dynamic content as the interface IDynamicContentBase. I don't know if it's a requirement that the dynamic content implement this but try implementing this or inherit from the base class (DynamicContentBase) and see if this fixes the issue.


Regards
Linus Ekström
EPiServer Development Team

#58508
Apr 27, 2012 9:43
Vote:
 

I ended up with

[DynamicContentPlugIn(
        DisplayName = "Name",
        Url = "EditControl.ascx" )]
public class MyClass : IDynamicContent, IDynamicContentDisplayType
{
    /* Code */
}

using State and Render() for the output. I was hoping it would be possible to keep two user controls like I had in the start but I didn't manage to get RenderAsBlockElement to work before I made it into a regular class.

#58515
Apr 27, 2012 12:17
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.