Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely CMS
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

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 also can use the DynamicContentPlugInAttribute on an User Control without implementing any interfaces.

C#
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 find this information helpful? Please log in to provide feedback.

Last updated: Sep 21, 2015

Recommended reading