How to get Custom Fields value dynamically
Hi,
Hello Pravat,
To get/set the value of a custom field through, you can use out extension methods GetValue() and SetValue() (please add a reference to Telerik.Sitefinity.Model in your class). For example, you might check the implementetion from the code sample we provided in this forum thread.
Kind regards,
Boyan Barnev
the Telerik team
Hi,
I have created custom thumbnail selector control in news item. I want to display my thumbnail image in news list template. I have integrated the below code in custom template, but getting 'Error parsing the template' . please help.
<%@ Control Language="C#" %>
<%@ 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" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit"
Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="samples" Namespace="Telerik.Sitefinity.Samples" Assembly="ThumbnailSelectorField" %>
<
script
runat
=
"server"
>
protected void NewsList_OnItemDataBound(object sender, RadListViewItemEventArgs e)
if (e.Item is RadListViewDataItem)
RadListViewDataItem item = e.Item as RadListViewDataItem;
string Content = (item.DataItem as Telerik.Sitefinity.News.Model.NewsItem).Content;
HtmlGenericControl divContent = e.Item.FindControl("divContent") as HtmlGenericControl;
if (divContent != null)
divContent.InnerHtml = Content.Substring(0, 20);
</
script
>
<
h1
>
News</
h1
>
<
div
class
=
"newsList"
>
<
telerik:RadListView
ID
=
"NewsList"
ItemPlaceholderID
=
"ItemsContainer"
runat
=
"server"
EnableEmbeddedSkins
=
"false"
EnableEmbeddedBaseStylesheet
=
"false"
OnItemDataBound
=
"NewsList_OnItemDataBound"
>
<
LayoutTemplate
>
<
sf:ContentBrowseAndEditToolbar
ID
=
"MainBrowseAndEditToolbar"
runat
=
"server"
Mode
=
"Add"
>
</
sf:ContentBrowseAndEditToolbar
>
<
ul
class
=
"sfnewsList sfnewsListTitleDateSummary"
>
<
asp:placeholder
id
=
"ItemsContainer"
runat
=
"server"
/>
</
ul
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
li
class
=
"sfnewsListItem"
>
<
div
class
=
"sfImg"
>
<
samples:SimpleImageField
ID
=
"SimpleImageField1"
runat
=
"server"
DisplayMode
=
"Read"
Value='<%# Eval("ThumbnailURL")%>' />
</
div
>
<
h2
class
=
"sfnewsTitle"
>
<
a
>
<
sf:DetailsViewHyperLink
ID
=
"DetailsViewHyperLink1"
TextDataField
=
"Title"
ToolTipDataField
=
"Description"
runat
=
"server"
/>
</
a
>
</
h2
>
<
div
class
=
"sfnewsMetaInfo"
>
<
sf:FieldListView
ID
=
"PostDate"
runat
=
"server"
Format
=
" PublicationDate.ToLocal():MMM dd, yyyy"
/>
</
div
>
<
div
class
=
"sfnewsComment"
>
<
span
></
span
>
<
sf:CommentsBox
ID
=
"itemCommentsLink"
runat
=
"server"
CssClass
=
"sfnewsCommentsCount"
/>
</
div
>
<
a
class
=
"sfnewsFullStory"
>
<
div
id
=
"divContent"
runat
=
"server"
>
</
div
>
</
a
>
<
sf:ContentBrowseAndEditToolbar
ID
=
"BrowseAndEditToolbar"
runat
=
"server"
Mode
=
"Edit,Delete,Unpublish"
>
</
sf:ContentBrowseAndEditToolbar
>
</
li
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
div
>