Exemplo n.º 1
0
        protected override void OnPreRender(EventArgs args)
        {
            if (!string.IsNullOrEmpty(SiteMarkerName))
            {
                var portalViewContext = new PortalViewContext(
                    new PortalContextDataAdapterDependencies(
                        PortalCrmConfigurationManager.CreatePortalContext(PortalName),
                        PortalName,
                        Context.Request.RequestContext));

                var target = portalViewContext.SiteMarkers.Select(SiteMarkerName);

                if (target != null)
                {
                    NavigateUrl = new UrlBuilder(target.Url);

                    if (string.IsNullOrEmpty(Text) && Controls.Count == 0)
                    {
                        var contentFormatter = PortalCrmConfigurationManager.CreateDependencyProvider(PortalName).GetDependency <ICrmEntityContentFormatter>(GetType().FullName) ?? new PassthroughCrmEntityContentFormatter();

                        Text = contentFormatter.Format(target.Entity.GetAttributeValue <string>("adx_name"), target.Entity, this);
                    }
                }
                else if (AutoHiddenIfAbsent ?? true)
                {
                    Visible = false;
                }
            }

            if (!string.IsNullOrEmpty(QueryString))
            {
                // we need to append these querystring parameters
                if (!NavigateUrl.Contains("?"))
                {
                    NavigateUrl += "?";
                }

                if (!NavigateUrl.EndsWith("?"))
                {
                    NavigateUrl += "&";
                }

                NavigateUrl += QueryString;
            }
        }
        protected override void OnPreRender(EventArgs args)
        {
            if (!string.IsNullOrEmpty(SiteMarkerName))
            {
                var portal  = PortalCrmConfigurationManager.CreatePortalContext(PortalName);
                var context = portal.ServiceContext;
                var website = portal.Website;

                var page = context.GetPageBySiteMarkerName(website, SiteMarkerName);

                if (page != null)
                {
                    page.AssertEntityName("adx_webpage");

                    NavigateUrl = portal.ServiceContext.GetUrl(page);

                    if (string.IsNullOrEmpty(Text) && Controls.Count == 0)
                    {
                        var contentFormatter = PortalCrmConfigurationManager.CreateDependencyProvider(PortalName).GetDependency <ICrmEntityContentFormatter>(GetType().FullName) ?? new PassthroughCrmEntityContentFormatter();

                        Text = contentFormatter.Format(page.GetAttributeValue <string>("adx_name"), page, this);
                    }
                }
            }

            if (!string.IsNullOrEmpty(QueryString))
            {
                // we need to append these querystring parameters
                if (!NavigateUrl.Contains("?"))
                {
                    NavigateUrl += "?";
                }

                if (!NavigateUrl.EndsWith("?"))
                {
                    NavigateUrl += "&";
                }

                NavigateUrl += QueryString;
            }
        }