+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Control Properties not showing when set via code

Control Properties not showing when set via code

5 posts, 0 answered
  1. derek
    derek avatar
    37 posts
    Registered:
    15 Jun 2007
    13 Apr 2009
    Link to this post
    We're running Sitefinity 3.6 hotfix.

    We have a script that automatically creates pages and controls. Some of the controls get properties set by the script.

    We've found that while the properties are being set, if you go in to set the properties manually afterwards, many of the settings do not show up. This is a problem as when you save your new settings, any of the hidden settings then get lost.

    Some examples:

    Not showing (but set behind the scenes)

    Telerik.News.WebControls.NewsView.MaximumListCount
    Telerik.News.WebControls.NewsView.LimitListCount
    Telerik.News.WebControls.NewsView.ItemListTemplatePath
    Telerik.News.WebControls.NewsView.SingleItemUrl

    One exception:
    Telerik.News.WebControls.NewsView.FilterExpression DOES show up after being set in code.

    This same issue occurs for the Telerik.Events.WebControls.EventsView control we set in code.

    Anyone else seeing this when setting control properties?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    14 Apr 2009
    Link to this post
    Hello derek,

    Could you paste some code snipped that illustrates the problem you have. I have not encountered this behavior.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. derek
    derek avatar
    37 posts
    Registered:
    15 Jun 2007
    14 Apr 2009
    Link to this post
    Ivan, here are some snippets from setting the properties on one of the controls and saving the page:

    // Retrieve the page because adding a control calls commit 
     
                        newPage = (ICmsPage)cmsManager.GetPage(newPage.ID, true); 
     
                        // Declare control 
     
                        Telerik.News.WebControls.NewsView newnewsView1 = new Telerik.News.WebControls.NewsView(); 
     
                        newsView1.ID = "newsView1"
     
                        // Set control properties 
     
                        newsView1.FilterExpression = "Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category IN (\"" + iFeaturedNewsCategory.CategoryName + "\") AND Tag.Name = \"" + iNewsTag.TagName + "\""; 
     
                        newsView1.ItemListTemplatePath = this.FeatureNewsItemListTemplatePath; 
     
                        newsView1.SingleItemUrl = newPage.StaticUrl.Substring(0, newPage.StaticUrl.LastIndexOf('.')) + "/" + this.AutoGeneratePageType + "_" + "News.aspx"; 
     
                        newsView1.LimitListCount = true
     
                        newsView1.MaximumListCount = 4
     
                        // Add the control to the placeholder  
     
                        newPage.Staged.AddControl("Content", newsView1); 
     
      
     
      
     
    // Save the new page 
     
                    newPage = savePage(newPage); 
     
      
     
      
     
    public ICmsPage savePage(ICmsPage page) 
     
            { 
     
                // Retrieve the page for edit 
     
                page = (ICmsPage)cmsManager.GetPage(page.ID, true); 
     
                //Check in the page 
     
                page.Staged.CheckIn(); 
     
                // Save the page 
     
                cmsManager.SavePage(page); 
     
                return page; 
     
            } 

  4. Dido
    Dido avatar
    149 posts
    Registered:
    24 Sep 2012
    20 Apr 2009
    Link to this post
    Hi derek,

    The very first thing that grabbed my attention is that you set the filter expression manually. While this might work, it is not recommended to so. Instead, you should use Telerik.Cms.Engine.ContentViewFiltering.ContentFilterBuilder, found in Telerik.Cms.Engine.dll . As the documentation states:
    "
    This class provides a black-box implementation for building and parsing FilterExpression property of all ContentView based controls. The idea of this class is to support various implementations of filters that have been introduced over the past and hence provide backward compatibility, while at the same time, translation mechanisms inside of the class will allow the filtering to always be done by taking advantage of the newest ContentManager API (and the most performant one). Introduction of this class allows us to change the way content is being filtered, while not breaking the API of ContentView based controls.
    "

    Another thing that I don't understand. Why would you use complex logic for setting the url, when you can use the property by itself?

    IStagedPage is published. Those check-in and check-out methods are private use only.

    Furthermore, you should not use the ItemListTemplatePath. You should map the NewsView mode's template to an external one.

    I haven't been able to reproduce the problem. I set programatically all properties, and there is no problem with them.

    Which is the version that you use?

    Regards,
    Dido
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Rory
    Rory avatar
    44 posts
    Registered:
    22 Mar 2012
    25 Apr 2012
    Link to this post
    so where is ContentFilterBuilder located now, in version 5?  where's the documentation for version 5?
Register for webinar
5 posts, 0 answered