More in this section

Forums / Developing with Sitefinity / NewsView current mode detection?

NewsView current mode detection?

2 posts, 0 answered
  1. Yordan
    Yordan avatar
    6 posts
    Registered:
    13 Feb 2009
    22 Feb 2009
    Link to this post
    Hello,

    NewsView's BehaviourMode propery is set to Auto. How can be programatically detected whether it is currently displaying a single item (Details mode) or the content list (Master mode)?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Feb 2009
    Link to this post
    Hello Yordan,

    Please find the example below that will return the current mode used.

    bool isInDetailsMode = false
     
            switch (NewsView1.BehaviorMode) 
            { 
                case Telerik.Cms.Engine.WebControls.ContentView.BehaviorModes.Detail: 
                    isInDetailsMode = true
                    break
                case Telerik.Cms.Engine.WebControls.ContentView.BehaviorModes.Master: 
                    isInDetailsMode = false
                    break
                case Telerik.Cms.Engine.WebControls.ContentView.BehaviorModes.Auto: 
                    isInDetailsMode = !String.IsNullOrEmpty(Context.Request[NewsView1.ContentItemKey]); 
                    break
            } 
     
            if (isInDetailsMode) 
                Response.Write("Control is displaying one single item."); 
            else 
                Response.Write("Control is displaying all items."); 

    Note that DetailsMode is obsolete.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered