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

Forums / Developing with Sitefinity / Set UrlEvaluationMode globally for a control

Set UrlEvaluationMode globally for a control

2 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    31 May 2013
    Link to this post
    I have a custom class which inherits from DynamicContentView...so I'd like to put some code in there to tell the control to ALWAYS render in UrlEvaluation mode QueryString.

    Problem is, there's no setter on the property so I can't?
  2. Stoimen Stoimenov
    Stoimen Stoimenov avatar
    60 posts
    Registered:
    11 Jul 2016
    14 Jun 2013
    Link to this post
    Hi,

     This is how the get for UrlEvaluationMode internally works:

    public UrlEvaluationMode UrlEvaluationMode
    {
        get
        {
            if (this.Page != null)
            {
                var urlEvalMode = this.Page.Items[RouteHandler.UrlEvaluationModeKey];
                if (urlEvalMode != null)
                {
                    return (UrlEvaluationMode)urlEvalMode;
                }
            }
            return default(UrlEvaluationMode);
        }
    }

    And is called from InitializeMasterView method in DynamicContentView

    So what I am suggesting is override the InitializeMasterView and set the correct value for this.Page.Items[RouteHandler.UrlEvaluationModeKey]

    Here is sample code that should do the trick:

    public class CustomContentView : DynamicContentView
    {
        protected override void InitializeMasterView()
        {
            this.Page.Items[RouteHandler.UrlEvaluationModeKey] = UrlEvaluationMode.QueryString;
            base.InitializeMasterView();
        }
    }


    Regards,
    Stoimen Stoimenov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered