How to get Custom Fields value dynamically

Posted by Community Admin on 04-Aug-2018 08:56

How to get Custom Fields value dynamically

All Replies

Posted by Community Admin on 11-Nov-2011 00:00

Hi,
 I have created a custom field module for thumbnail selector in new module by using Telerik.Sitefinity.Samples.SimpleImageFieldElement,  which i got from your forums. It is working fine. How can I retrive the custom fileds(Thumbnail) value in code behind. Please send me the sample as soon as possible.

Thanks & Regards,
Pravat Sharma

Posted by Community Admin on 11-Nov-2011 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 14-Nov-2011 00:00

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>

This thread is closed