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

Forums / Set-up & Installation / 3.7 SP4 Upgrade Broke NewsView Display in Page Edit Mode

3.7 SP4 Upgrade Broke NewsView Display in Page Edit Mode

5 posts, 1 answered
  1. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    02 Nov 2010
    Link to this post
    Hi,
        I'm having a problem with my NewsView control in page edit mode. Since we upgraded our site from 3.7.2022 to 3.7.2136 using the "...NET40_patch.zip" file, the NewsView control now displays the following error...


    Error Rendering Control - NewsView1 An unhandled exception has occurred.
    Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.


    The control renders fine on the live site. This behavior exists across all of our dev and live environments with different databases. Have you seen this error before?

    Thanks,
    VectorLord
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Nov 2010
    Link to this post
    Hi VectorLord,

    There is no problem with the default NewsView control. You can check its behavior at our demo website.
    Most probably you have modified the template or the control and you use some control that requires Page object in edit mode, which is null when you edit a page.

    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. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    02 Nov 2010
    Link to this post
    You're right! We are using a custom control to display the news, but I looked before (and again just now) and don't see where we could be referencing the Page object. Maybe I'm overlooking something, here's the code for the control...

    001.<%@ Control Language="C#" %>
    002. 
    003.<script type="text/C#" runat="server">
    004.    protected void Page_Load(object sender, EventArgs e)
    005.    {
    006.        string newsTagId = Request.QueryString["NewsTagID"];
    007.        if (!string.IsNullOrEmpty(newsTagId))
    008.        {
    009.            Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager("News");
    010.            Guid tagGuid = new Guid(newsTagId);
    011.            Telerik.Cms.Engine.ITag selectedTag = contentManager.GetTag(tagGuid);
    012.            if (selectedTag != null)
    013.            {
    014.                if (!string.IsNullOrEmpty(selectedTag.TagName))
    015.                {
    016.                    tagFilterDisplayContainer.Visible = true;
    017.                    tagFilterDisplay.Text = string.Format("<div class=\"newsTagFilterDisplay\">Showing news articles tagged with <strong><em>'{0}'</em></strong></div>", selectedTag.TagName);
    018.                }
    019.            }
    020.        }
    021.    }
    022.     
    023.     
    024.    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    025.    {
    026.        Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager();
    027.        Telerik.Cms.Engine.IContent article = e.Item.DataItem as Telerik.Cms.Engine.IContent;
    028.        if (article != null)
    029.        {
    030.            IList listOfAllTags = contentManager.GetTags(article.ID);
    031.            if (listOfAllTags.Count > 0)
    032.            {
    033.                e.Item.FindControl("tagsLabel").Visible = true;
    034.                e.Item.FindControl("tagsPlaceholder").Visible = true;
    035.            }
    036.            else
    037.            {
    038.                e.Item.FindControl("tagsLabel").Visible = false;
    039.                e.Item.FindControl("tagsPlaceholder").Visible = false;
    040.            }
    041. 
    042.            if (article.GetMetaData("Source").ToString().Length == 0)
    043.            {
    044.                e.Item.FindControl("pblock_Source").Visible = false;
    045.            }
    046.        }
    047.    }
    048. 
    049. 
    050.    protected void pager1_Load(object sender, EventArgs e)
    051.    {
    052.        if (((Telerik.Cms.Web.UI.Pager)sender).PageCount == 0)
    053.        {
    054.            pager1.Visible = false;
    055.            showArchiveLinkOnly.Visible = true;
    056.        }
    057.    }
    058. 
    059. 
    060.    protected void ClearTagFilterButton_Click(object sender, EventArgs e)
    061.    {
    062.        // Test
    063.    }
    064.</script>
    065. 
    066.<telerik:CssFileLink ID="CssFileLink1" EmbeddedFileName="Telerik.News.Resources.ControlTemplates.Frontend.newsCommonLayout.css" FileName="" Media="screen" runat="server" />
    067.<telerik:RadFormDecorator ID="formDecorator1" runat="server" Skin="Office2007" DecoratedControls="All" />
    068. 
    069.<asp:Panel ID="tagFilterDisplayContainer" runat="server" Visible="false" CssClass="tagFilterDisplayContainer">
    070.    <asp:Button ID="clearTagFilterButton" runat="server" PostBackUrl="~/Default.aspx" Text="Clear Tag" Width="66" />
    071.    <asp:Literal ID="tagFilterDisplay" runat="server" />
    072.    <div class="clearer"> </div>
    073.</asp:Panel>
    074. 
    075.<asp:Repeater ID="repeater" runat="server" OnItemDataBound="repeater_ItemDataBound">
    076.    <HeaderTemplate>
    077.        <ul class="sf_newsList">
    078.    </HeaderTemplate>
    079.    <ItemTemplate>
    080.        <li style="list-style-type:none;">
    081.            <p class="sf_newsTitle">
    082.                <asp:Literal ID="Title" runat="server"></asp:Literal>
    083.            </p>
    084.            <p class="sf_newsDate">
    085.                <asp:Literal ID="Publication_Date" runat="server" Text="{0}" /><span class="sf_newsAuthor">  |  <asp:Literal ID="Author" runat="server"></asp:Literal></span>
    086.            </p>
    087.            <asp:Panel id="pnlNewsContent" runat="server" CssClass="sf_newsContent">
    088.                <asp:Literal ID="content" runat="server"></asp:Literal>
    089.            </asp:Panel>
    090.            <p id="pblock_Source" runat="server" class="sf_newsSource">
    091.                <asp:Literal ID="Source" runat="server"></asp:Literal>
    092.            </p>
    093.            <div class="sf_postTags">
    094.                <div id="tagsLabel" runat="server" class="sf_postTagsLabel">Tags</div>
    095.                <div id="tagsPlaceholder" runat="server" class="sf_postTagsPlaceholder">
    096.                    <asp:Repeater ID="Tags" runat="server">
    097.                        <ItemTemplate>
    098.                            <asp:HyperLink ID="tagLink" runat="server" />
    099.                        </ItemTemplate>
    100.                    </asp:Repeater>
    101.                </div>
    102.                <div class="clearer"> </div>
    103.            </div>
    104.        </li>
    105.    </ItemTemplate>
    106.    <FooterTemplate>
    107.        </ul>
    108.    </FooterTemplate>
    109.</asp:Repeater>
    110. 
    111.<div class="pagerContainer">
    112.<div class="pagerDivider"> </div>
    113.<telerik:Pager ID="pager1" runat="server" OnLoad="pager1_Load">
    114.    <LayoutTemplate>
    115.        <asp:Repeater ID="PageRepeaterLinkButton" runat="server">
    116.            <HeaderTemplate>
    117.                <ol class="sf_pager sf_pager_news">
    118.                <li><asp:LinkButton ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:LinkButton></li>
    119.            </HeaderTemplate>
    120.            <ItemTemplate>
    121.                <li>
    122.                    <asp:LinkButton ID="SingleItem" runat="server" />
    123.                </li>
    124.            </ItemTemplate>
    125.            <FooterTemplate>
    126.                <li><asp:LinkButton ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:LinkButton></li>
    127.                </ol>
    128.                <div class="newsArchiveLinkContainer"><a href="/Default/NewsArchive.aspx">> News Archive</a></div>
    129.            </FooterTemplate>
    130.        </asp:Repeater>
    131.        <asp:Repeater ID="PageRepeaterHyperLink" runat="server">
    132.            <HeaderTemplate>
    133.                <ol class="sf_pager sf_pager_news">
    134.                <li><asp:HyperLink ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:HyperLink></li>
    135.            </HeaderTemplate>
    136.            <ItemTemplate>
    137.                <li>
    138.                    <asp:HyperLink ID="SingleItem" runat="server" />
    139.                </li>
    140.            </ItemTemplate>
    141.            <FooterTemplate>
    142.                <li><asp:HyperLink ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:HyperLink></li>
    143.                </ol>
    144.                <div class="newsArchiveLinkContainer"><a href="/Default/NewsArchive.aspx">> News Archive</a></div>
    145.            </FooterTemplate>
    146.        </asp:Repeater>
    147.    </LayoutTemplate>
    148.</telerik:Pager>
    149.<div id="showArchiveLinkOnly" runat="server" visible="false">
    150.    <div class="pagerDivider"> </div>
    151.    <div class="newsArchiveLinkContainer"><a href="/Default/NewsArchive.aspx">> News Archive</a></div>
    152.</div>
    153.<div class="clearer"> </div>
    154.</div>


    Thanks,
    VectorLord
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Nov 2010
    Link to this post
    Hi VectorLord,

    The problem is in the RadFormDecorator. You can add the control dynamically if the page is not null or if you are not in the context of cmspagemode == edit.

    Another option is showing a user friendly message when you are in edit mode.

    Sincerely yours,
    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
    Answered
  5. VectorLord
    VectorLord avatar
    24 posts
    Registered:
    28 Sep 2009
    02 Nov 2010
    Link to this post
    That was it!

    My simple solution was to just slip the FormDecorator inside the tagFilterDisplayContainer panel, which is only displayed when the news is filtered by a tag. Obviously, this condition will never exist in the page editor (at least how we're using it).

    Thanks!
    VectorLord
Register for webinar
5 posts, 1 answered