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.
Ability to reuse already developed functionality is one of the most convincing reasons to base your module on Generic Content module and not build a module from scratch. However, the module that is being built will necessary be different than the one we are basing it on - otherwise it would make no sense to build a new module - we could just use the existing one.
So far we have seen and learned how to reuse functionality - in this article we are going to examine different approaches for removing or abandoning functionality implemented on Generic Content module.
There are two basic ways to remove functionality:
Let us suppose we are to remove comments functionality from our Products module. Since we have added ProductsCommentsView in the ProductsControlPanel View, we can simply comment that line out, like follows:
/// <summary> |
/// Loads configured views. |
/// </summary> |
protected override void CreateViews() |
{ |
AddView<ProductsView>("ProductsView", "ProductsView_Title", "ProductsView_Description", "all", Messages.ResourceManager); |
AddView<ProductsCategoriesView>("ProductsCategoriesView", "CategoriesView_Title", "CategoriesView_Description", "all", Messages.ResourceManager); |
AddView<ProductsTagsView>("ProductsTagsView", "TagsView_Title", "TagsView_Description", "all", Messages.ResourceManager); |
//AddView<ProductsCommentsView>("ProductsCommentsView", "CommentsView_Title", |
// "CommentsView_Description", "all", Messages.ResourceManager); |
AddView<ProductsPermissionsView>("ProductsPermissionsView", "PermissionsView_Title", "PermissionsView_Description", "globalPerm", Messages.ResourceManager); |
} |
Modify the View to restrict its abilities
To achieve this, all we need to do is following:
Wrap the details panel into a server control. We’ll do this by editing the embedded for the ProductsPreviewView template located in Telerik.Samples.Products.Resources.ControlTemplates.Backend.ProductsPreviewView.ascx in following manner:
<div id="detailsPanel" runat="server" class="details"> |
<h3> |
<asp:Literal Text="<%$Resources:Details %>" runat="server" /> |
</h3> |
<dl> |
<asp:Repeater ID="repeaterItemMetaData" runat="server"> |
<ItemTemplate> |
<dt> |
<asp:Literal ID="lblKey" runat="server" /> |
</dt> |
<dd> |
<asp:Literal ID="lblValue" runat="server" /> |
</dd> |
</ItemTemplate> |
</asp:Repeater> |
</dl> |
</div> |
Next, in the ProductsPreviewView class, we’ll add a reference to the detailsPanel control.
protected Control DetailsPanel |
{ |
get |
{ |
return base.Container.GetControl<Control>("detailsPanel", false); |
} |
} |
protected override void InitializeControls(System.Web.UI.Control viewContainer) |
{ |
base.InitializeControls(viewContainer); |
if(this.DetailsPanel != null) |
this.DetailsPanel.Visible = false; |
} |
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.