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

Forums / Developing with Sitefinity / dummy Icontent values

dummy Icontent values

3 posts, 0 answered
  1. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    02 Feb 2009
    Link to this post
    I have a control that retrieves a list of icontent from the news module. it then uses the first item in the IList array to populate content on the page. however, if the list is empty, this first item is null, so the page breaks.

    what I would like to do is create a dummy icontent with "not found" type responses, such as:

    newsItem = mgr.Content.CreateContent(

    "text/html");
    newsItem.Url =
    "/news.aspx";
    newsItem.SetMetaData(
    "Title", "View All News");
    newsItem.SetMetaData(
    "Publication_Date", DateTime.Now);
    newsItem.SetMetaData(
    "Thumbnail", "~/images/news/notfound.gif");

    so that if the list is empty, the control will populate with an appropriate message. However, is this going to clutter the database with staged content that never gets used? is there another way to instantiate IContent without calling CreateContent()?

     

  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    05 Feb 2009
    Link to this post
    Hi SelArom,

    This is not going to create a record in the database. This is more like opening a transaction, but without committing it. The record is created whenever you call SaveContent() method.
    I wonder why don't you create an item, which you get (GetContent() with specific ID) when you need an IContent instance? This way, you will create it only once, you will have it stored and you will use it whenever you need it.

    Kind regards,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    05 Feb 2009
    Link to this post
    I thought about doing that, but I didn't think having a fake news item in the list was a good idea, since we have an archive. I also didn't like the idea of hard coding an ID into the lookup. since this is only created when there is no news (hasn't happened in the year that I've been here) I think it makes more sense to just make a value up on the spot...

    thanks for the feedback!
Register for webinar
3 posts, 0 answered