Loading...

Last updated: Dec 09 2016

Area: Episerver CMS Applies to versions: 10 and higher
Other versions:

Creating a Hello World dynamic content plug-in (Legacy)

Note: Dynamic content is deprecated. Use blocks instead. While existing solutions will continue to work, you should not build new solutions on this API. It will be phased out in the future.

The following example creates a dynamic content plug-in by implementing the IDynamicContentView interface.

For convenience, you inherit DynamicContentBase which implements IDynamicContentBase. You then add IDynamicContentView which supports both MVC and Web Forms.

Note: This example uses the DynamicContentPlugInAttribute, but only for registering the plug-in. You can also use the DynamicContentPlugInAttribute on a User Control without implementing any interfaces.

using System;
using System.IO;
using EPiServer.Core;
using EPiServer.DynamicContent;

namespace CodeSamples.DynamicContent
{
    [DynamicContentPlugIn(
        DisplayName = "ClassDynamicContentPlugin",
        Description = "Example of a Dynamic Content plugin as a simple class.")]
    public class ClassDynamicContentPlugin : DynamicContentBase, IDynamicContentView
    {
        public ClassDynamicContentPlugin()
        {
        }

        public void Render(TextWriter writer)
        {
            writer.Write("<div>Hello World</div>");
        }
    }
}

Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/