Class BlockController<TBlockData>
Provides the base implementation for for block controllers.
Inherited Members
Namespace: EPiServer.Web.Mvc
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7Syntax
public abstract class BlockController<TBlockData> : PartialContentController<TBlockData>, IRenderTemplate<TBlockData>, IRenderTemplate where TBlockData : BlockData
Type Parameters
Name | Description |
---|---|
TBlockData | The type of the block data. |
Examples
The following code example demonstrates two simple block controllers.
/// <summary>
/// Simple controller for a block. The base class will delegate the block to a view with the same name as the block type (MyBlock).
/// </summary>
public class EmptyBlockControllerSample : BlockController<MyBlock>
{
}
/// <summary>
/// Controller for a block, which handles it's index action.
/// </summary>
public class BlockControllerSample : BlockController<MyBlock>
{
public override ActionResult Index(MyBlock blockData)
{
return PartialView("MyBlock", blockData);
}
}
/// <summary>
/// Simple block
/// </summary>
[ContentType]
public class MyBlock : BlockData
{
public virtual string MyString { get; set; }
}
public class PageControllerSample : PageController<MyPage>
{
public ActionResult Index(MyPage blockData)
{
return View(blockData);
}
}
[ContentType]
public class MyPage : PageData
{
public virtual MyBlock TheBlock { get; set; }
}
Constructors
BlockController()
Declaration
protected BlockController()