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.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
Telerik.Sitefinity.DynamicModules.Web.UI.Frontend;
namespace
SitefinityWebApp.OfficesModule
{
public
class
DynamicContentViewCustom : DynamicContentView
{
protected
DynamicContentViewMaster MasterViewControl
{
get
{
if
(
this
.masterViewControl ==
null
)
{
this
.masterViewControl =
new
DynamicContentViewMasterCustom(
this
.DynamicManager);
}
return
this
.masterViewControl;
}
set
{
this
.masterViewControl = value;
}
}
protected
override
void
InitializeMasterView()
{
if
(
this
.HasValidRelatedDataConfiguration &&
this
.RelatedItemsIds !=
null
)
{
this
.MasterViewControl.SourceItemsIds =
this
.RelatedItemsIds;
}
this
.MasterViewControl.TemplateKey =
string
.IsNullOrEmpty(
this
.MasterViewDefinition.TemplateKey) ?
this
.DefaultMasterTemplateKey :
this
.MasterViewDefinition.TemplateKey;
this
.MasterViewControl.DynamicContentType =
this
.DynamicContentType;
this
.MasterViewControl.MasterViewDefinition =
this
.MasterViewDefinition;
this
.MasterViewControl.UrlEvaluationMode =
this
.UrlEvaluationMode;
this
.MasterViewControl.UrlKeyPrefix =
this
.UrlKeyPrefix;
this
.Controls.Add(
this
.MasterViewControl);
}
private
DynamicContentViewMaster masterViewControl;
}
}
DynamicContentViewMaster
class now has a Host property which allows you to easily access the DynamicContentView
(which is the Host) for its master/details view. This change requires you to modify the above code slightly, so if you are using Sitefinity 6.1 or higher version of our product, please use this sample instead:using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
Telerik.Sitefinity.DynamicModules.Web.UI.Frontend;
namespace
SitefinityWebApp.OfficesModule
{
public
class
DynamicContentViewCustom : DynamicContentView
{
protected
DynamicContentViewMaster MasterViewControl
{
get
{
if
(
this
.masterViewControl ==
null
)
{
this
.masterViewControl =
new
DynamicContentViewMasterCustom(
this
.DynamicManager);
this
.masterViewControl.Host =
this
;
}
return
this
.masterViewControl;
}
set
{
this
.masterViewControl = value;
}
}
protected
override
void
InitializeMasterView()
{
if
(
this
.HasValidRelatedDataConfiguration &&
this
.RelatedItemsIds !=
null
)
{
this
.MasterViewControl.SourceItemsIds =
this
.RelatedItemsIds;
}
this
.MasterViewControl.TemplateKey =
string
.IsNullOrEmpty(
this
.MasterViewDefinition.TemplateKey) ?
this
.DefaultMasterTemplateKey :
this
.MasterViewDefinition.TemplateKey;
this
.MasterViewControl.DynamicContentType =
this
.DynamicContentType;
this
.MasterViewControl.MasterViewDefinition =
this
.MasterViewDefinition;
this
.MasterViewControl.UrlEvaluationMode =
this
.UrlEvaluationMode;
this
.MasterViewControl.UrlKeyPrefix =
this
.UrlKeyPrefix;
this
.Controls.Add(
this
.MasterViewControl);
}
private
DynamicContentViewMaster masterViewControl;
}
}
<%@ Control Language="C#" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Fields" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
span
>City</
span
>
<
br
/>
<
asp:TextBox
ID
=
"cityTextBox"
runat
=
"server"
/>
<
br
/>
<
span
>Country</
span
>
<
br
/>
<
asp:TextBox
ID
=
"countryTextBox"
runat
=
"server"
/>
<
br
/>
<
span
>ZipCode</
span
>
<
br
/>
<
asp:TextBox
ID
=
"zipCodeTextBox"
runat
=
"server"
/>
<
br
/>
<
asp:Button
ID
=
"searchBtn"
Text
=
"Search"
runat
=
"server"
/>
<
telerik:RadListView
ID
=
"dynamicContentListView"
ItemPlaceholderID
=
"ItemsContainer"
runat
=
"server"
EnableEmbeddedSkins
=
"false"
EnableEmbeddedBaseStylesheet
=
"false"
>
<
LayoutTemplate
>
<
ul
class
=
"sfitemsList sfitemsListTitleDateTmb"
>
<
asp:PlaceHolder
ID
=
"ItemsContainer"
runat
=
"server"
/>
</
ul
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
li
class
=
"sfitem sfClearfix"
>
<
h2
class
=
"sfitemTitle"
>
<
sf:DetailsViewHyperLink
ID
=
"DetailsViewHyperLink"
TextDataField
=
"Title"
runat
=
"server"
/>
</
h2
>
<
sf:FieldListView
ID
=
"PublicationDate"
runat
=
"server"
Format
=
"{PublicationDate.ToLocal():MMM d, yyyy, HH:mm tt}"
WrapperTagName
=
"div"
WrapperTagCssClass
=
"sfitemPublicationDate"
/>
</
li
>
</
ItemTemplate
>
</
telerik:RadListView
>
<
sf:Pager
ID
=
"pager"
runat
=
"server"
></
sf:Pager
>
<
asp:PlaceHolder
ID
=
"socialOptionsContainer"
runat
=
"server"
></
asp:PlaceHolder
>
#region Control References
protected
virtual
TextBox CityTextBox
{
get
{
return
this
.Container.GetControl<TextBox>(
"cityTextBox"
,
true
);
}
}
protected
virtual
TextBox CountryTextBox
{
get
{
return
this
.Container.GetControl<TextBox>(
"countryTextBox"
,
true
);
}
}
protected
virtual
TextBox ZipCodeTextBox
{
get
{
return
this
.Container.GetControl<TextBox>(
"zipCodeTextBox"
,
true
);
}
}
protected
virtual
Button SearchButton
{
get
{
return
this
.Container.GetControl<Button>(
"searchBtn"
,
true
);
}
}
#endregion
protected
override
void
InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
{
SearchButton.Click += SearchButton_Click;
base
.InitializeControls(container);
}
void
SearchButton_Click(
object
sender, EventArgs e)
{
var dataSource = ((IEnumerable<DynamicContent>)
this
.DynamicContentListView.DataSource);
if
(!
this
.CityTextBox.Text.IsNullOrEmpty())
dataSource = dataSource.Where(itm => itm.GetValue(cityFieldName).ToString().Contains(CityTextBox.Text));
if
(!
this
.CountryTextBox.Text.IsNullOrEmpty())
dataSource = dataSource.Where(itm => itm.GetValue(countryFieldName).ToString().Contains(CountryTextBox.Text));
if
(!
this
.ZipCodeTextBox.Text.IsNullOrEmpty())
dataSource = dataSource.Where(itm => itm.GetValue(zipFieldName).ToString().Contains(ZipCodeTextBox.Text));
this
.DynamicContentListView.DataSource = dataSource.ToList();
}
<
add
enabled
=
"True"
type
=
"Telerik.Sitefinity.DynamicModules.Web.UI.Frontend.DynamicContentView, Telerik.Sitefinity"
title
=
"OfficesCustom"
cssClass
=
"sfNewsViewIcn"
moduleName
=
"Offices"
DynamicContentTypeName
=
"Telerik.Sitefinity.DynamicTypes.Model.Offices.Office"
DefaultMasterTemplateKey
=
"3fc7803a-47fd-6966-a5dc-ff0000f47b12"
DefaultDetailTemplateKey
=
"40c7803a-47fd-6966-a5dc-ff0000f47b12"
visibilityMode
=
"None"
name
=
"Telerik.Sitefinity.DynamicTypes.Model.Offices.Office"
/>
<
add
enabled
=
"True"
type
=
"SitefinityWebApp.OfficesModule.DynamicContentViewCustom"
title
=
"OfficesCustom"
cssClass
=
"sfNewsViewIcn"
moduleName
=
"Offices"
DynamicContentTypeName
=
"Telerik.Sitefinity.DynamicTypes.Model.Offices.Office"
DefaultMasterTemplateKey
=
"3fc7803a-47fd-6966-a5dc-ff0000f47b12"
DefaultDetailTemplateKey
=
"40c7803a-47fd-6966-a5dc-ff0000f47b12"
visibilityMode
=
"None"
name
=
"Telerik.Sitefinity.DynamicTypes.Model.Offices.Office"
/>
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.