The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]
The code for a Custom Control based command panel for our sample books module looks like following:
using System.Web.UI.WebControls; |
using Telerik.Cms.Web.UI; |
using Telerik.Web; |
namespace Samples.Books.WebControls |
{ |
/// <summary> |
/// Custom control which is used for command panel |
/// </summary> |
public class BooksCommandPanel : ViewModeControl<BooksControlPanel>, ICommandPanel |
{ |
/// <summary> |
/// Initializes a new instance of the <see cref="BooksCommandPanel"/> class. |
/// </summary> |
/// <param name="ctrlPnl">The CTRL PNL.</param> |
public BooksCommandPanel(IControlPanel ctrlPnl) |
{ |
this.ctrlPnl = ctrlPnl; |
} |
/// <summary> |
/// Gets or sets the path to a custom layout template for the control. |
/// </summary> |
/// <remarks> |
/// We are overriding this property only to add attribute to it. The attribute will be used in future |
/// for the template mapping / exporting tool. |
/// </remarks> |
[WebSysTemplate(BooksCommandPanel.BooksCommandPanelTemplateName, |
"BooksCommandPanelTemplateName_Template_Desc", "/Books/", false, "2000-01-25")] |
public override string LayoutTemplatePath |
{ |
get |
{ |
return base.LayoutTemplatePath; |
} |
set |
{ |
base.LayoutTemplatePath = value; |
} |
} |
/// <summary> |
/// Gets the name of the embedded layout template. If the control uses layout template this |
/// property must be overridden to provide the path (key) to an embedded resource file. |
/// </summary> |
/// <value>Name of the resource with embedded template</value> |
protected override string LayoutTemplateName |
{ |
get |
{ |
return BooksCommandPanel.BooksCommandPanelTemplateName; |
} |
} |
#region Control references |
/// <summary> |
/// Gets all books. |
/// </summary> |
/// <value>All books.</value> |
protected virtual HyperLink AllBooks |
{ |
get { return base.Container.GetControl<HyperLink>("allBooks", true); } |
} |
/// <summary> |
/// Gets the sales. |
/// </summary> |
/// <value>The sales.</value> |
protected virtual HyperLink Sales |
{ |
get { return base.Container.GetControl<HyperLink>("sales", true); } |
} |
#endregion |
/// <summary> |
/// Initializes all controls instantiated in the layout container. This method is called at appropriate time for setting initial values and subscribing for events of layout controls. |
/// </summary> |
/// <param name="viewContainer">The control that will host the current view.</param> |
protected override void InitializeControls(System.Web.UI.Control viewContainer) |
{ |
base.InitializeControls(viewContainer); |
this.AllBooks.NavigateUrl = CreateRootViewCommand(typeof (BooksControlPanel), typeof (BooksListView)); |
this.Sales.NavigateUrl = CreateRootViewCommand(typeof (BooksControlPanel), typeof (BooksSalesView)); |
} |
/// <summary> |
/// Refreshes the command panel information. |
/// </summary> |
/// <requirements> |
/// This method could be used to refresh the command panel information. For example |
/// when there is some change in the ControlPanel which reflects on the information of the |
/// CommandPanel. |
/// </requirements> |
/// <example> |
/// You can refer to <see cref="T:Telerik.Web.ICommandPanel">ICommandPanel</see> interface for more |
/// complicated example implementing the whole |
/// <see cref="T:Telerik.Web.ICommandPanel">ICommandPanel</see> interface. |
/// </example> |
public void Refresh() |
{ |
this.ChildControlsCreated = false; |
} |
/// <summary> |
/// Reference to the control panel tied to the command panel instance. |
/// </summary> |
/// <remarks> |
/// This property is used for communication between the command panel and its control |
/// panel. |
/// </remarks> |
/// <example> |
/// You can refer to <see cref="T:Telerik.Web.ICommandPanel">ICommandPanel</see> interface for more |
/// complicated example implementing the whole |
/// <see cref="T:Telerik.Web.ICommandPanel">ICommandPanel</see> interface. |
/// </example> |
public IControlPanel ControlPanel |
{ |
get { return this.ctrlPnl; } |
} |
private IControlPanel ctrlPnl; |
private const string BooksCommandPanelTemplateName = |
"Samples.Books.Resources.ControlTemplates.Backend.BooksCommandPanel.ascx"; |
} |
} |
/// <summary> |
/// Creates the custom command panels. |
/// </summary> |
/// <param name="viewMode">The view mode.</param> |
/// <param name="list">The list.</param> |
protected override void CreateCustomCommandPanels(string viewMode, System.Collections.Generic.List<Telerik.Web.ICommandPanel> list) |
{ |
list.Add(new BooksCommandPanel(this)); |
} |
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.