More in this section

Forums / Developing with Sitefinity / Custom news control doesn't show details

Custom news control doesn't show details

4 posts, 0 answered
  1. medo
    medo avatar
    9 posts
    Registered:
    22 Nov 2009
    22 Jan 2010
    Link to this post
    I've created a user control to show a list of newsitems with full content instead of summary.
    I've added a NewsView control
    <cc1:NewsView ID="NewsView1" runat="server" BookmarkEnabled="false" RenderPagerAsLink="true">   
     
     

     

    and added a <ItemListTemplate>
    which is the same as the original exept I've added: 

    <asp:Literal ID="content" runat="server"></asp:Literal> 

    and removed de summary literal.
    The usercontrol also has a Page_Load with

     

            NewsView1.FilterExpression = @"Publication_Date <= ""#now"" AND Expiration_Date > ""#now""";  
            NewsView1.SortExpression="Publication_Date DESC"

     
    I've added the ascx to the toolbar and added de controls to my news.aspx page.

    Everything works and the page is rendered as expected, if I however click on a link( news title) to show a single newsitem I get:
     

     

    Server Error in '/' Application.

    The resource cannot be found.

     

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /news/10-01-15/Debitel_Netherlands_acquired_by_KPN_NL.aspx

     

     

     

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Jan 2010
    Link to this post
    Hi medo,

    1. RadEditor control supports FormatCode block, so you can use it when you paste any code or some kind of snippet.

    2. On News.aspx page you should have NewsView control that will be responsible for showing the items in details mode. You can even set the NewsView control BehaviorMode to Details which will not render any list content, but your single item content.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. medo
    medo avatar
    9 posts
    Registered:
    22 Nov 2009
    22 Jan 2010
    Link to this post
    There already is a NewsView control on the news.aspx page.
    To be precise there is a FullNews.ascx control that has a newsview control


    <cc1:NewsView ID="NewsView1" runat="server" BookmarkEnabled="false" RenderPagerAsLink="true" BehaviorMode="Auto"
    PS the format code block produces this crappy result. so here it is again.

    &lt;

     

    cc1:NewsView ID="NewsView1" runat="server" BookmarkEnabled="false" RenderPagerAsLink="true" BehaviorMode="Auto"&gt;

     

    Is this not good enough, should I add a "normal" newsview to the page?
    Where do I set the BehaviorMode to Details on a newsview that is dynamically added to the page?
    I cant seem to find the behaviourmode property under advanced.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Jan 2010
    Link to this post
    Hello medo,

    Add the highlighted logic in the code behind of your user control

    [Telerik.Web.UrlRewriterService("Telerik.Cms.Engine.ContentUrlRewriterService, Telerik.Cms.Engine")]
    public partial class HERE IS THE NAME OF YOUR USER CONTROL CLASS: System.Web.UI.UserControl

    2. Remove the control from your page and then add it again.

    Below is as sample code

    <%@ Register TagPrefix="sf" Namespace="Telerik.News.WebControls"  Assembly="Telerik.News" %>
    <sf:NewsView runat="server" ID="NewsView1" BehaviorMode="Auto" ProviderName="News"></sf:NewsView>


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
     
    [Telerik.Web.UrlRewriterService("Telerik.Cms.Engine.ContentUrlRewriterService, Telerik.Cms.Engine")]
    public partial class CustomControls_TestQuery : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
     
        }
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered