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

Forums / Developing with Sitefinity / Extending NewView control resource problems

Extending NewView control resource problems

5 posts, 0 answered
  1. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    26 May 2010
    Link to this post
    I've extended NewView control.

    The list is ok (/Home.aspx), but when I go to the NewsPage (Detail)(/News/Sub/date/name.aspx) it crashes a script

    /WebResource.axd?d=wL2LWJiVpmJBS7mfGuhEXOSojBpyGc5Ohf29bT1zpujbfeXv9azV9GRl7zExggrlVZBmiNIOjsui-UV__VX2toPCeY1ssaq7ItykJ-5NVkvbu4FOelctKFXnzetHskOX0&t=634104874018439180
    <html>
        <head>
            <title>The resource cannot be found.</title>

    What could it be? I didn't try to add anything, it might be something inherit with a wrong assembly name.
    How can I fix it?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    26 May 2010
    Link to this post
    Hi Bruno Michels,

    1. Can you reproduce the problem with the built-in control?

    2. Can you share some base code that you use and the problem can be reproduce with it?

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    26 May 2010
    Link to this post
    1. No

    2.
    - Create a new Class Library Project
    - Add NewsHeader.ascx and NewsHeader.ascx.cs
    NewsHeader.ascx (just the full external template)
    NewsHeader.ascx.cs
    namespace Sitefinity.News
    {
        public class NewsHeader : Telerik.News.WebControls.NewsView
        {
            public override string SingleItemTemplateName
            {
                get
                {
                    return "Sitefinity.News.NewsHeader.ascx";
                }
            }
        }
    }

    - Add reference to the DLL in web.config
    - Drag n' drop the control on a page
    - Drag n' drop a NewsView (List mode) on another page and set the full view to the other page
    - Click the news

    The page will load with but will fail to load a /Webresource
  4. Bruno Michels
    Bruno Michels avatar
    125 posts
    Registered:
    16 Apr 2010
    26 May 2010
    Link to this post
    I just realized that in the external template there were a CssFileLink referencing the assembly and not a external css.

    Removing that solved my problem, thanks anyway.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    26 May 2010
    Link to this post
    Hi Bruno Michels,

    You should override SingleItemTemplatePath property. Below are two samples

    - when the templates are not embedded


    public class NewsViewCustomControl : NewsView
    {
     
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx";
            }
     
        }
     
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx";
            }
     
        }
     
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
     
        public override Type AssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
    }

    - when the templates are embedded

    namespace NewsViewCustomControl
    {
        public class News : NewsView
        {
            public override string ItemListTemplateName
            {
                get
                {
                    return News.NewsViewCustomItemListTemplateName;
                }
            }
     
            /// <summary>
            /// Gets the name of the embedded layout template. If the control uses layout template
            /// this property must be overridden to provide the path (key) to an embedded resource file.
            /// </summary>
            /// <value></value>
            public override string SingleItemTemplateName
            {
                get
                {
                    return News.NewsViewCustomSingleItemTemplateName;
                }
            }
     
            public override Type AssemblyInfo
            {
                get
                {
                    return typeof(News);
                }
                set
                {
                    base.AssemblyInfo = value;
                }
            }
     
     
     
            #region Constants
     
            private const string NewsViewCustomItemListTemplateName = "NewsViewCustomControl.Resources.ListPageMaster.ascx";
     
            private const string NewsViewCustomSingleItemTemplateName = "NewsViewCustomControl.Resources.ListPageDetails.ascx";
     
            #endregion
        }
    }


    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
5 posts, 0 answered