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.
Yep, I did it again; started a series without an introduction. Romi pointed out to my ill practice, so here I am, writing an introduction in the fourth part of the series.
ContentView designers were introduced in Sitefinity 3.2. Their purpose is to allow end users simple and quick way of editing a control without going to the property grid – in other words – they are the “basic” mode that you see when you edit ContentView based control. You can find built-in ContentView designers on following controls:
ContentView designer is a control.
Take a look at the Figure 1 to see how does the EventsView ContentView designer looks like when you edit the EventsView control.
Figure 1: EventsView designer (both screens)
[ControlDesignerAttribute("Telerik.Events.WebControls.Design.EventsViewDesigner, Telerik.Events")] |
public class EventsView : ContentView, ICategorizedControl |
{ |
// ... |
} |
/// <summary> |
/// EventsView designer control |
/// </summary> |
public class EventsViewDesigner : ContentViewDesignerBase |
{ |
public override string DesignerTemplatePath |
{ |
get |
{ |
if (ViewState["DesignerTemplatePath"] == null) |
return "~/Sitefinity/Admin/ControlTemplates/Events/Design/EventsViewControlDesigner.ascx"; |
return ViewState["DesignerTemplatePath"] as string; |
} |
set |
{ |
ViewState["DesignerTemplatePath"] = value; |
} |
} |
} |
Well, things are starting to clear up now, aren’t they? ContentViewDesignerBase class is a very flexible class which works very well with the two controls that are the heart of the designers. Now, open the following file to examine those controls:
~/Sitefinity/Admin/ControlTemplates/Events/Design/EventsViewControlDesigner.ascx
Let’s examine the PresentationModes control first:
<sfDesign:PresentationModes ID="presentationModes" runat="server"> |
<Modes> |
<sfDesign:PresentationMode ID="listPageMode" runat="server" |
ModeTitle="List & page" |
ModeSettingsId="ModesSettings1" |
MasterTemplatePath="~/Sitefinity/ControlTemplates/Events/Modes/ListPageMaster.ascx" |
DetailTemplatePath="~/Sitefinity/ControlTemplates/Events/Modes/ListPageDetail.ascx" |
CssClass="pageListMode" |
SelectedCssClass="selectedOption pageListMode" |
> |
<Template> |
<asp:RadioButton ID="listPageRadio" runat="server" /> |
<p>A list of event titles, dates and summaries (optional). The full event info is opened in a separate page.</p> |
</Template> |
</sfDesign:PresentationMode> |
<sfDesign:PresentationMode ID="ExpandableList" runat="server" |
ModeTitle="Expandable list" |
ModeSettingsId="ModesSettings2" |
MasterTemplatePath="~/Sitefinity/ControlTemplates/Events/Modes/ExpandableListMaster.ascx" |
CssClass="expandableList" |
SelectedCssClass="selectedOption expandableList" |
> |
<Template> |
<asp:RadioButton ID="ExpandableListRadio" runat="server" /> |
<p>A list of event titles and dates. The full info is expanded in the same list when a title is clicked.</p> |
</Template> |
</sfDesign:PresentationMode> |
<sfDesign:PresentationMode ID="allInAListMode" runat="server" |
ModeTitle="Expanded list" |
ModeSettingsId="ModesSettings3" |
MasterTemplatePath="~/Sitefinity/ControlTemplates/Events/Modes/AllPostsListMaster.ascx" |
CssClass="allInListMode" |
SelectedCssClass="selectedOption allInListMode"> |
<Template> |
<asp:RadioButton ID="allPostsInAListRadio" runat="server" /> |
<p>All events with their titles and the full info are in a common page.</p> |
</Template> |
</sfDesign:PresentationMode> |
</Modes> |
</sfDesign:PresentationModes> |
As you can see the PresentationModes control (in Events designer) has Modes collection and three PresentationMode controls defined inside of this selection. Let’s take a brief look at the ModeTitle properties of these modes:
Sounds familiar? Take a look at the Figure 2:
Figure 2: three presentation modes defined in the template
One of the major features of this approach is that you can now predefine the different modes for your end user and she can load it by simply selecting the mode. Looking through the file system to find the right templates is not necessary anymore.
Remember the ModeSettingID property of the PresentationMode control I’ve described in the previous paragraph? That property associates particular mode with the specific PresentationModeSettings control. Now, I’ve talked quite a lot about this control in the previous posts of this series, so I won’t go into details here. The important thing to note, however, is that for each mode you can have different set of settings.
There are three ideas behind the ContentView designers that you can take advantage of:
I hope that this has cleared the whole “designers situation” a bit more clear. In the next few posts I’ll wrap it up with demonstration of how to create custom setting and how to implement custom designer on the custom ContentView based control… and then we can move on – FilterExpression and ContentFilterBuilder class, perhaps.
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.