Page Loading issue

Posted by Community Admin on 04-Aug-2018 20:03

Page Loading issue

All Replies

Posted by Community Admin on 28-Feb-2012 00:00

I have created a customer widget for displaying news based off of a similar 3.7 custom code.  After spending a lot of time I have the widget working, or so I think.  I can load it onto a page, and view the page no problem.  However once I publish the page, then go back to edit the same page, it never finishes loading.  All I get is the animation at the top of the page going back and forth.  There are no errors in the log, and I get no exceptions from .net. 
Here is my code, sorry for the length:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using Telerik.Sitefinity;
using Telerik.Sitefinity.News.Model;
using Telerik.Sitefinity.Modules.News;
using Telerik.Sitefinity.Web.UI.ControlDesign;
using Telerik.Sitefinity.GenericContent.Model;
using Telerik.Sitefinity.Taxonomies;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Taxonomies.Model;
 
namespace SitefinityWebApp.Custom.Widgets.NewsListControl
    [ControlDesigner(typeof(NewsListDesigner))]
    public partial class NewsList : System.Web.UI.UserControl
    
        //Declare class variables
        NewsManager manager;
        private int _numOfNewsArticles = 5; //Default number of news articles displayed
        private string _categoryFilter = ""; //Default category filter
        private string _cssClass = "news"; //Default style class
        private string _title = "News"; //Default control title
        private DateTime _maxPublishDate = DateTime.Now.AddMonths(-3); //Furthest date to show for news
 
 
        protected Guid GetTaxon(string Category)
        
            TaxonomyManager Manager = new TaxonomyManager();
            var taxa = Manager.GetTaxa<HierarchicalTaxon>().Where(t => t.Name == Category).Single();
            return taxa.Id;
        
 
        protected void Page_Load(object sender, EventArgs e)
        
            //Set Style Class
            controlContainer.Attributes.Clear();
            controlContainer.Attributes.Add("class", cssClass);
 
            //Set Title
            controlTitle.Text = title;
 
            //Set container for news items
            List<NewsItem> CEANews = new List<NewsItem>();
             
            //Initialize news data manager
            manager = NewsManager.GetManager();
            CEANews = App.WorkWith()
                .NewsItems()
                .Where(n => n.Status == ContentLifecycleStatus.Live)
                .Where(n => n.PublicationDate < DateTime.Now.AddMonths(-3))
                .Where(n => n.GetValue<IList<Guid>>("Category").Contains(GetTaxon("Legislative News")))
                .Get()
                .Take(this.numOfNewsArticles)
                .ToList();
 
            //CEANews = manager.GetNewsItems().Where(newsItem => newsItem.Status == ContentLifecycleStatus.Live).ToList();
            /*string sortExpression = "Publication_Date DESC";
 
            //Build metadata filter
            List<IMetaSearchInfo> newsFilter = new List<IMetaSearchInfo>();
            newsFilter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "Category", CategoryFilter.Trim()));
            newsFilter.Add(new MetaSearchInfo(MetaValueTypes.DateTime, "Publication_Date", DateTime.Now.ToString(), SearchCondition.LessOrEqual));
            newsFilter.Add(new MetaSearchInfo(MetaValueTypes.DateTime, "Expiration_Date", DateTime.Now.ToString(), SearchCondition.GreaterThen));
 
            //Retrieve the news articles based on the requested number of articles, sort expression, and applied metadata filters
            IList listOfNewsItems = manager.Content.GetContent(0, NumberOfNewsArticles, sortExpression, newsFilter.ToArray());
 
            //Bind the results of the news article search to the web control's repeater
            newsListRpter.DataSource = listOfNewsItems;*/
            //CEANews.RemoveAll(FindByDate);
            CEANews.Sort(delegate(NewsItem C1, NewsItem C2)
            
                return C1.PublicationDate.CompareTo(C2.PublicationDate);
            );
            newsListRpter.DataSource = CEANews;
            newsListRpter.DataBind();
 
        
 
        private static bool FindByDate(NewsItem NI)
        
            if (NI.PublicationDate < DateTime.Now.AddMonths(-3))
            
                return true;
            
            else
            
                return false;
            
        
 
        //Formats the News List's archive link based on the control's news category
        public string FormatMoreLink()
        
            //Initialize news data manager and path variables
            /*manager = new NewsManager("News");
            string rootPath, pathVariable, fullPath;
            string categoryId = "";
 
            //Retrieve the root path for the more line
            rootPath = ResolveUrl("~/aboutus/publications/news.aspx");
 
            //Format path variable string
            pathVariable = "?NewsCatId=";
 
            //Get Guid for the control's news category
            ICategory newsCategory = manager.Content.GetCategory(CategoryFilter);
            if (newsCategory != null)
            
                categoryId = newsCategory.ID.ToString();
            
 
            //Build the full path
            fullPath = rootPath + pathVariable + categoryId;
 
            //Return the formated news archive link*/
            return "null";
 
        
 
        //Formats the news article's URL based on the partial link provided by the NewsManager module
        public string FormatLink(string partialLink)
        
            //Retrieve the root path for the link
            string rootPath = ResolveUrl("~/aboutus/publications/news");
 
            //Construct the full path for the news article based on the root path and the provided partial link
            string fullPath = rootPath + partialLink + ".aspx";
 
            return fullPath;
        
 
        //Returns the string as a datetime object
        protected DateTime GetDateTime(string date)
        
            DateTime response = new DateTime();
 
            response = DateTime.Parse(date);
 
            return response;
        
 
        //Get or set the number of news articles displayed by the user control
        public int numOfNewsArticles
        
            get return _numOfNewsArticles;
 
            set _numOfNewsArticles = value;
        
 
        //Ger or set the category filter for the user control
        public string categoryFilter
        
            get return _categoryFilter;
 
            set _categoryFilter = value;
        
 
        //Get or set the CSS class for the user control
        public string cssClass
        
            get return _cssClass;
 
            set _cssClass = value;
        
 
        //Get or set the title for the user control
        public string title
        
            get return _title;
 
            set _title = value;
        
 
        //Get or set the maximum publication date
        public DateTime maxPublishDate
        
            get return _maxPublishDate;
            set _maxPublishDate = value;
        
    

Posted by Community Admin on 28-Feb-2012 00:00

Forget it.  Of all things it was a very minor formatting issue on the ascx that was causing the issue.

This thread is closed