/// <devdoc>
        /// <para>A protected method. Populates iteratively the specified <see cref='System.Web.UI.WebControls.SiteMapNodeItem'/> with a
        ///    sub-hierarchy of child controls.</para>
        /// </devdoc>
        protected virtual void InitializeItem(SiteMapNodeItem item) {
            Debug.Assert(_mergedCurrentNodeStyle != null && _mergedRootNodeStyle != null);

            ITemplate template = null;
            Style style = null;
            SiteMapNodeItemType itemType = item.ItemType;
            SiteMapNode node = item.SiteMapNode;

            switch (itemType) {
                case SiteMapNodeItemType.Root:
                    template = RootNodeTemplate != null ? RootNodeTemplate : NodeTemplate;
                    style = _mergedRootNodeStyle;
                    break;

                case SiteMapNodeItemType.Parent:
                    template = NodeTemplate;
                    style = _nodeStyle;
                    break;

                case SiteMapNodeItemType.Current:
                    template = CurrentNodeTemplate != null ? CurrentNodeTemplate : NodeTemplate;
                    style = _mergedCurrentNodeStyle;
                    break;

                case SiteMapNodeItemType.PathSeparator:
                    template = PathSeparatorTemplate;
                    style = _pathSeparatorStyle;
                    break;
            }

            if (template == null) {
                if (itemType == SiteMapNodeItemType.PathSeparator) {
                    Literal separatorLiteral = new Literal();
                    separatorLiteral.Mode = LiteralMode.Encode;
                    separatorLiteral.Text = PathSeparator;
                    item.Controls.Add(separatorLiteral);
                    item.ApplyStyle(style);
                }
                else if (itemType == SiteMapNodeItemType.Current && !RenderCurrentNodeAsLink) {
                    Literal currentNodeLiteral = new Literal();
                    currentNodeLiteral.Mode = LiteralMode.Encode;
                    currentNodeLiteral.Text = node.Title;
                    item.Controls.Add(currentNodeLiteral);
                    item.ApplyStyle(style);
                }
                else {
                    HyperLink link = new HyperLink();

                    if (style != null && style.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
                        link.Font.Underline = style.Font.Underline;

                    link.EnableTheming = false;
                    link.Enabled = this.Enabled;
                    // VSWhidbey 281869 Don't modify input when url pointing to unc share
                    if (node.Url.StartsWith("\\\\", StringComparison.Ordinal)) {
                        link.NavigateUrl = ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url));
                    }
                    else {
                        link.NavigateUrl = Context != null ?
                            Context.Response.ApplyAppPathModifier(ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url))) : node.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(node.Title);
                    if (ShowToolTips)
                        link.ToolTip = node.Description;
                    item.Controls.Add(link);
                    link.ApplyStyle(style);
                }
            }
            else {
                template.InstantiateIn(item);
                item.ApplyStyle(style);
            }
        }
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            switch (item.ItemType)
            {
            case SiteMapNodeItemType.Root:
                if (RootNodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(RootNodeStyle);
                    RootNodeTemplate.InstantiateIn(item);
                }
                else if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(RootNodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else
                {
                    WebControl c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    c.ApplyStyle(RootNodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.Current:
                if (CurrentNodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    CurrentNodeTemplate.InstantiateIn(item);
                }
                else if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else if (RenderCurrentNodeAsLink)
                {
                    HyperLink c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    c.ApplyStyle(CurrentNodeStyle);
                    item.Controls.Add(c);
                }
                else
                {
                    Literal c = CreateLiteral(item);
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.Parent:
                if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else
                {
                    WebControl c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.PathSeparator:
                if (PathSeparatorTemplate != null)
                {
                    item.ApplyStyle(PathSeparatorStyle);
                    PathSeparatorTemplate.InstantiateIn(item);
                }
                else
                {
                    Literal h = new Literal();
                    h.Text = HttpUtility.HtmlEncode(PathSeparator);
                    item.ApplyStyle(PathSeparatorStyle);
                    item.Controls.Add(h);
                }
                break;
            }
        }
Example #3
0
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            switch (item.ItemType) {
                case SiteMapNodeItemType.Root:
                    if (RootNodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (RootNodeStyle);
                        RootNodeTemplate.InstantiateIn (item);
                    }
                    else if (NodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (RootNodeStyle);
                        NodeTemplate.InstantiateIn (item);
                    }
                    else {
                        WebControl c = CreateHyperLink (item);
                        c.ApplyStyle (NodeStyle);
                        c.ApplyStyle (RootNodeStyle);
                        item.Controls.Add (c);
                    }
                    break;

                case SiteMapNodeItemType.Current:
                    if (CurrentNodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (CurrentNodeStyle);
                        CurrentNodeTemplate.InstantiateIn (item);
                    }
                    else if (NodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (CurrentNodeStyle);
                        NodeTemplate.InstantiateIn (item);
                    } else if (RenderCurrentNodeAsLink) {
                        HyperLink c = CreateHyperLink (item);
                        c.ApplyStyle (NodeStyle);
                        c.ApplyStyle (CurrentNodeStyle);
                        item.Controls.Add (c);
                    } else {
                        Literal c = CreateLiteral (item);
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (CurrentNodeStyle);
                        item.Controls.Add (c);
                    }
                    break;

                case SiteMapNodeItemType.Parent:
                    if (NodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        NodeTemplate.InstantiateIn (item);
                    }
                    else {
                        WebControl c = CreateHyperLink (item);
                        c.ApplyStyle (NodeStyle);
                        item.Controls.Add (c);
                    }
                    break;

                case SiteMapNodeItemType.PathSeparator:
                    if (PathSeparatorTemplate != null) {
                        item.ApplyStyle (PathSeparatorStyle);
                        PathSeparatorTemplate.InstantiateIn (item);
                    }
                    else {
                        Literal h = new Literal ();
                        h.Text = PathSeparator;
                        item.ApplyStyle (PathSeparatorStyle);
                        item.Controls.Add (h);
                    }
                    break;
            }
        }
Example #4
0
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            ITemplate           nodeTemplate = null;
            Style               s            = null;
            SiteMapNodeItemType itemType     = item.ItemType;
            SiteMapNode         siteMapNode  = item.SiteMapNode;

            switch (itemType)
            {
            case SiteMapNodeItemType.Root:
                nodeTemplate = (this.RootNodeTemplate != null) ? this.RootNodeTemplate : this.NodeTemplate;
                s            = this._mergedRootNodeStyle;
                break;

            case SiteMapNodeItemType.Parent:
                nodeTemplate = this.NodeTemplate;
                s            = this._nodeStyle;
                break;

            case SiteMapNodeItemType.Current:
                nodeTemplate = (this.CurrentNodeTemplate != null) ? this.CurrentNodeTemplate : this.NodeTemplate;
                s            = this._mergedCurrentNodeStyle;
                break;

            case SiteMapNodeItemType.PathSeparator:
                nodeTemplate = this.PathSeparatorTemplate;
                s            = this._pathSeparatorStyle;
                break;
            }
            if (nodeTemplate == null)
            {
                if (itemType == SiteMapNodeItemType.PathSeparator)
                {
                    Literal child = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = this.PathSeparator
                    };
                    item.Controls.Add(child);
                    item.ApplyStyle(s);
                }
                else if ((itemType == SiteMapNodeItemType.Current) && !this.RenderCurrentNodeAsLink)
                {
                    Literal literal2 = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = siteMapNode.Title
                    };
                    item.Controls.Add(literal2);
                    item.ApplyStyle(s);
                }
                else
                {
                    HyperLink link = new HyperLink();
                    if ((s != null) && s.IsSet(0x2000))
                    {
                        link.Font.Underline = s.Font.Underline;
                    }
                    link.EnableTheming = false;
                    link.Enabled       = this.Enabled;
                    if (siteMapNode.Url.StartsWith(@"\\", StringComparison.Ordinal))
                    {
                        link.NavigateUrl = base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url));
                    }
                    else
                    {
                        link.NavigateUrl = (this.Context != null) ? this.Context.Response.ApplyAppPathModifier(base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url))) : siteMapNode.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(siteMapNode.Title);
                    if (this.ShowToolTips)
                    {
                        link.ToolTip = siteMapNode.Description;
                    }
                    item.Controls.Add(link);
                    link.ApplyStyle(s);
                }
            }
            else
            {
                nodeTemplate.InstantiateIn(item);
                item.ApplyStyle(s);
            }
        }
Example #5
0
        /// <devdoc>
        /// <para>A protected method. Populates iteratively the specified <see cref='System.Web.UI.WebControls.SiteMapNodeItem'/> with a
        ///    sub-hierarchy of child controls.</para>
        /// </devdoc>
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            Debug.Assert(_mergedCurrentNodeStyle != null && _mergedRootNodeStyle != null);

            ITemplate           template = null;
            Style               style    = null;
            SiteMapNodeItemType itemType = item.ItemType;
            SiteMapNode         node     = item.SiteMapNode;

            switch (itemType)
            {
            case SiteMapNodeItemType.Root:
                template = RootNodeTemplate != null ? RootNodeTemplate : NodeTemplate;
                style    = _mergedRootNodeStyle;
                break;

            case SiteMapNodeItemType.Parent:
                template = NodeTemplate;
                style    = _nodeStyle;
                break;

            case SiteMapNodeItemType.Current:
                template = CurrentNodeTemplate != null ? CurrentNodeTemplate : NodeTemplate;
                style    = _mergedCurrentNodeStyle;
                break;

            case SiteMapNodeItemType.PathSeparator:
                template = PathSeparatorTemplate;
                style    = _pathSeparatorStyle;
                break;
            }

            if (template == null)
            {
                if (itemType == SiteMapNodeItemType.PathSeparator)
                {
                    Literal separatorLiteral = new Literal();
                    separatorLiteral.Mode = LiteralMode.Encode;
                    separatorLiteral.Text = PathSeparator;
                    item.Controls.Add(separatorLiteral);
                    item.ApplyStyle(style);
                }
                else if (itemType == SiteMapNodeItemType.Current && !RenderCurrentNodeAsLink)
                {
                    Literal currentNodeLiteral = new Literal();
                    currentNodeLiteral.Mode = LiteralMode.Encode;
                    currentNodeLiteral.Text = node.Title;
                    item.Controls.Add(currentNodeLiteral);
                    item.ApplyStyle(style);
                }
                else
                {
                    HyperLink link = new HyperLink();

                    if (style != null && style.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
                    {
                        link.Font.Underline = style.Font.Underline;
                    }

                    link.EnableTheming = false;
                    link.Enabled       = this.Enabled;
                    // VSWhidbey 281869 Don't modify input when url pointing to unc share
                    if (node.Url.StartsWith("\\\\", StringComparison.Ordinal))
                    {
                        link.NavigateUrl = ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url));
                    }
                    else
                    {
                        link.NavigateUrl = Context != null?
                                           Context.Response.ApplyAppPathModifier(ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url))) : node.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(node.Title);
                    if (ShowToolTips)
                    {
                        link.ToolTip = node.Description;
                    }
                    item.Controls.Add(link);
                    link.ApplyStyle(style);
                }
            }
            else
            {
                template.InstantiateIn(item);
                item.ApplyStyle(style);
            }
        }
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            ITemplate nodeTemplate = null;
            Style s = null;
            SiteMapNodeItemType itemType = item.ItemType;
            SiteMapNode siteMapNode = item.SiteMapNode;
            switch (itemType)
            {
                case SiteMapNodeItemType.Root:
                    nodeTemplate = (this.RootNodeTemplate != null) ? this.RootNodeTemplate : this.NodeTemplate;
                    s = this._mergedRootNodeStyle;
                    break;

                case SiteMapNodeItemType.Parent:
                    nodeTemplate = this.NodeTemplate;
                    s = this._nodeStyle;
                    break;

                case SiteMapNodeItemType.Current:
                    nodeTemplate = (this.CurrentNodeTemplate != null) ? this.CurrentNodeTemplate : this.NodeTemplate;
                    s = this._mergedCurrentNodeStyle;
                    break;

                case SiteMapNodeItemType.PathSeparator:
                    nodeTemplate = this.PathSeparatorTemplate;
                    s = this._pathSeparatorStyle;
                    break;
            }
            if (nodeTemplate == null)
            {
                if (itemType == SiteMapNodeItemType.PathSeparator)
                {
                    Literal child = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = this.PathSeparator
                    };
                    item.Controls.Add(child);
                    item.ApplyStyle(s);
                }
                else if ((itemType == SiteMapNodeItemType.Current) && !this.RenderCurrentNodeAsLink)
                {
                    Literal literal2 = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = siteMapNode.Title
                    };
                    item.Controls.Add(literal2);
                    item.ApplyStyle(s);
                }
                else
                {
                    HyperLink link = new HyperLink();
                    if ((s != null) && s.IsSet(0x2000))
                    {
                        link.Font.Underline = s.Font.Underline;
                    }
                    link.EnableTheming = false;
                    link.Enabled = this.Enabled;
                    if (siteMapNode.Url.StartsWith(@"\\", StringComparison.Ordinal))
                    {
                        link.NavigateUrl = base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url));
                    }
                    else
                    {
                        link.NavigateUrl = (this.Context != null) ? this.Context.Response.ApplyAppPathModifier(base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url))) : siteMapNode.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(siteMapNode.Title);
                    if (this.ShowToolTips)
                    {
                        link.ToolTip = siteMapNode.Description;
                    }
                    item.Controls.Add(link);
                    link.ApplyStyle(s);
                }
            }
            else
            {
                nodeTemplate.InstantiateIn(item);
                item.ApplyStyle(s);
            }
        }