Ejemplo n.º 1
0
        ///
        /// <summary>
        /// Raises the PreRender event.
        /// </summary>
        /// <remarks>
        /// Note for inheritors - for this control to function properly, any derived controls that override
        /// this method should ensure that they call this base method as part of their OnPreRender.
        /// </remarks>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        ///
        protected override void OnPreRender(EventArgs e)
        {
            _titleRow.ApplyStyle(TitleStyle);
            _titleLinkButton.ApplyStyle(TitleStyle);
            _titleHyperLink.ApplyStyle(TitleStyle);
            if (TitleStyle.Decoration.Length != 0)
            {
                _titleLinkButton.Attributes.Add("style", "text-decoration: " + TitleStyle.Decoration);
                _titleHyperLink.Attributes.Add("style", "text-decoration: " + TitleStyle.Decoration);
            }

            _bodyRow.ApplyStyle(BodyStyle);
            _bodyCell.ApplyStyle(BodyStyle);

            base.OnPreRender(e);

            Page.ClientScript.RegisterHiddenField(UniqueID + "_Hidden", IsExpanded().ToString());

            return;
        }
Ejemplo n.º 2
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)
        {
            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;
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 将此控件呈现给指定的输出参数,并使用指定的数据初始化控件。
        /// </summary>
        /// <param name="writer"> 接收控件内容的 HtmlTextWriter 编写器 </param>
        /// <param name="MenuXML">菜单文件名。</param>
        public void RenderControl(HtmlTextWriter writer, string MenuXML)
        {
            Thinksea.WebControls.Menu2.Menu menuConnection = new Thinksea.WebControls.Menu2.Menu(MenuXML); // 菜单数据库联接。

            string OutMenuHtmlText =                                                                       // 输出菜单 HTML 文本。
                                     @"<script type='text/javascript' id='clientEventHandlersJS'>
<!--
function Thinksea_WebControls_Menu2_menuChange_" + this.ID + @"(obj,menu)
{
	var controls = document.getElementById('"     + this.ID + @"').all;
	for (var i=0; i < controls.length; i++)
	{
		if( controls[i].id == menu )
		{
			menu = controls[i];
		}
	}
	if(menu.style.display=='')
	{"    ;

            if (this.MenuTitleCollapseStyle != null)
            {
                if (this.MenuTitleCollapseStyle.CssClass != null && this.MenuTitleCollapseStyle.CssClass != "")
                {
                    OutMenuHtmlText = OutMenuHtmlText + @"
		obj.className='"         + this.MenuTitleCollapseStyle.CssClass + @"';";
                }
                string styleStr = this.StyleToCssString(this.MenuTitleCollapseStyle);
                if (styleStr != "")
                {
                    OutMenuHtmlText = OutMenuHtmlText + @"
		obj.style.cssText='"         + styleStr + @"';";
                }
            }
            OutMenuHtmlText += @"
		menu.style.display='none';
	}else{"    ;
            if (this.MenuTitleStyle != null)
            {
                if (this.MenuTitleStyle.CssClass != null && this.MenuTitleStyle.CssClass != "")
                {
                    OutMenuHtmlText = OutMenuHtmlText + @"
		obj.className='"         + this.MenuTitleStyle.CssClass + @"';";
                }
                string styleStr = this.StyleToCssString(this.MenuTitleStyle);
                if (styleStr != "")
                {
                    OutMenuHtmlText = OutMenuHtmlText + @"
		obj.style.cssText='"         + styleStr + @"';";
                }
            }
            OutMenuHtmlText += @"
		menu.style.display='';
	}
}
//-->
		</script>"        ;

            System.Web.UI.WebControls.Panel MenuPanel = new System.Web.UI.WebControls.Panel();
            MenuPanel.ID = this.ID;
            if (this.Style["Z-INDEX"] != null)
            {
                MenuPanel.Style["Z-INDEX"] = this.Style["Z-INDEX"];
            }
            if (this.Style["POSITION"] != null)
            {
                MenuPanel.Style["POSITION"] = this.Style["POSITION"];
            }
            if (this.Style["LEFT"] != null)
            {
                MenuPanel.Style["LEFT"] = this.Style["LEFT"];
            }
            if (this.Style["TOP"] != null)
            {
                MenuPanel.Style["TOP"] = this.Style["TOP"];
            }
            MenuPanel.ApplyStyle(this.ControlStyle);
            MenuPanel.Enabled = this.Enabled;
            MenuPanel.Visible = this.Visible;

            int menuGroupCount = 0;       //菜单组数量
            int menuItemCount;            //菜单组中菜单项数量

            Thinksea.WebControls.Menu2.MenuGroup [] mgis = menuConnection.GetMenuGroup( );
            foreach (Thinksea.WebControls.Menu2.MenuGroup tmpmgis in mgis)
            {
                Thinksea.WebControls.Menu2.MenuItem [] miis = menuConnection.GetMenuItemOfMenuGroupIDWithAccessFilter(tmpmgis.ID, this.Powers);
                if (miis.Length > 0)
                {
                    menuItemCount = 0;

                    #region 菜单集合。
                    System.Web.UI.WebControls.Table MenuGroup = new System.Web.UI.WebControls.Table();
                    MenuGroup.Width       = new System.Web.UI.WebControls.Unit("100%");
                    MenuGroup.CellSpacing = 0;
                    MenuGroup.CellPadding = 0;

                    #region 菜单组标题
                    System.Web.UI.WebControls.TableRow MenuGroupTitleRow = new System.Web.UI.WebControls.TableRow();
                    MenuGroupTitleRow.Style["CURSOR"] = "hand";
                    #region
                    System.Web.UI.WebControls.TableCell MenuGroupTitleCell = new System.Web.UI.WebControls.TableCell();
                    if (tmpmgis.Expand)
                    {
                        MenuGroupTitleCell.ApplyStyle(this.MenuTitleStyle);
                    }
                    else
                    {
                        MenuGroupTitleCell.ApplyStyle(this.MenuTitleCollapseStyle);
                    }
                    MenuGroupTitleCell.Attributes["onclick"] = "Thinksea_WebControls_Menu2_menuChange_" + this.ID + "(this,'" + tmpmgis.ID.Replace("\"", "\\\"") + "');";

                    #region 填充菜单组标题
                    System.Web.UI.WebControls.Label TitleText = new System.Web.UI.WebControls.Label();
                    TitleText.ApplyStyle(this.MenuTitleOnMouseOutStyle);
                    if (this.MenuTitleOnMouseOverStyle != null)
                    {
                        string styleStr = this.StyleToCssString(this.MenuTitleOnMouseOverStyle);
                        if (styleStr != "")
                        {
                            TitleText.Attributes["onmouseover"] = "this.style.cssText='" + styleStr + "';";
                        }
                        else
                        {
                            if (this.MenuTitleOnMouseOverStyle.CssClass != null && this.MenuTitleOnMouseOverStyle.CssClass != "")
                            {
                                TitleText.Attributes["onmouseover"] = "this.className='" + this.MenuTitleOnMouseOverStyle.CssClass + "';";
                            }
                        }
                    }
                    if (this.MenuTitleOnMouseOutStyle != null)
                    {
                        string styleStr = this.StyleToCssString(this.MenuTitleOnMouseOutStyle);
                        if (styleStr != "")
                        {
                            TitleText.Attributes["onmouseout"] = "this.style.cssText='" + styleStr + "';";
                        }
                        else
                        {
                            if (this.MenuTitleOnMouseOutStyle.CssClass != null && this.MenuTitleOnMouseOutStyle.CssClass != "")
                            {
                                TitleText.Attributes["onmouseout"] = "this.className='" + this.MenuTitleOnMouseOutStyle.CssClass + "';";
                            }
                        }
                    }
                    TitleText.Text = tmpmgis.Text;

                    MenuGroupTitleCell.Controls.Add(TitleText);
                    #endregion

                    MenuGroupTitleRow.Cells.Add(MenuGroupTitleCell);
                    #endregion
                    MenuGroup.Rows.Add(MenuGroupTitleRow);
                    #endregion

                    #region 菜单项集合。
                    System.Web.UI.WebControls.TableRow MenuGroupRow = new System.Web.UI.WebControls.TableRow();
                    #region
                    System.Web.UI.WebControls.TableCell MenuGroupCell = new System.Web.UI.WebControls.TableCell();

                    #region
                    System.Web.UI.WebControls.Panel MenuGroupPanel = new System.Web.UI.WebControls.Panel();
                    MenuGroupPanel.ApplyStyle(this.MenuGroupStyle);
                    MenuGroupPanel.ID = tmpmgis.ID;
                    if (!tmpmgis.Expand)
                    {
                        MenuGroupPanel.Style["DISPLAY"] = "none";
                    }

                    #region 填充菜单项
                    int CellMaxCount = this.MaxColumn;    //用来控制每行最多显示的菜单项数量
                    int CellIndex    = 0;                 //当前显示的菜单项行索引。用来辅助CellMaxCount完成控制每行显示的菜单项数量
                    foreach (Thinksea.WebControls.Menu2.MenuItem tmpmiis in miis)
                    {
                        #region 插入菜单项分隔符
                        if (this.ShowMenuItemSeparator && CellIndex > 0)
                        {
                            System.Web.UI.WebControls.Label menuItemSeparator = new System.Web.UI.WebControls.Label();
                            menuItemSeparator.ApplyStyle(this.MenuItemSeparatorStyle);
                            MenuGroupPanel.Controls.Add(menuItemSeparator);
                        }
                        #endregion

                        #region 菜单项
                        System.Web.UI.WebControls.HyperLink MenuItem = new System.Web.UI.WebControls.HyperLink();
                        MenuItem.ApplyStyle(this.MenuItemStyle);
                        MenuItem.ID   = tmpmiis.ID;
                        MenuItem.Text = tmpmiis.Text;
                        if (this.Enabled)
                        {
                            if (tmpmiis.URL.Length == 0)
                            {
                                MenuItem.NavigateUrl = "javascript:" + this.Page.ClientScript.GetPostBackEventReference(this, "ItemID_" + tmpmiis.ID);
                            }
                            else
                            {
                                MenuItem.Target      = tmpmiis.Target;
                                MenuItem.NavigateUrl = tmpmiis.URL;
                            }
                            if (this.ItemDataBound != null)
                            {
                                this.ItemDataBound(this, new Thinksea.WebControls.Menu2.ItemEventArgs(MenuItem, tmpmiis));
                            }
                        }

                        MenuGroupPanel.Controls.Add(MenuItem);
                        #endregion

                        menuItemCount++;
                        CellIndex++;
                        if (CellIndex >= CellMaxCount)
                        {
                            CellIndex = 0;
                            System.Web.UI.WebControls.Literal MenuItemSplit = new System.Web.UI.WebControls.Literal();
                            MenuItemSplit.Text = "<br>";
                            MenuGroupPanel.Controls.Add(MenuItemSplit);
                        }
                    }
                    #endregion

                    MenuGroupCell.Controls.Add(MenuGroupPanel);
                    #endregion

                    MenuGroupRow.Cells.Add(MenuGroupCell);
                    #endregion
                    MenuGroup.Rows.Add(MenuGroupRow);
                    #endregion

                    if (menuItemCount > 0)
                    {
                        if (this.ShowMenuGroupSeparator && menuGroupCount > 0)
                        {
                            System.Web.UI.WebControls.Panel menuGroupSeparator = new System.Web.UI.WebControls.Panel();
                            menuGroupSeparator.ApplyStyle(this.MenuGroupSeparatorStyle);
                            MenuPanel.Controls.Add(menuGroupSeparator);
                        }
                        MenuPanel.Controls.Add(MenuGroup);
                        menuGroupCount++;
                    }
                    #endregion
                }
            }
            writer.Write(OutMenuHtmlText);
            MenuPanel.RenderControl(writer);
        }
        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);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates the control sub-components of the
 /// control.
 /// </summary>
 /// <remarks>
 /// Sets the user <see cref="_contentCell"/> container
 /// object render delegate as the
 /// <see cref="RenderPanelContent"/> method using the
 /// <see cref="Control.SetRenderMethodDelegate">
 /// SetRenderMethodDelegate</see> method. This allows
 /// the content (this panel control) to be rendered as a 
 /// child object of the <see cref="_contentCell"/> container.
 /// </remarks>
 private void CreateControlComponents()
 {
     // Create the header panel and
     // set its state to this control state.
     _headerPanel = new Panel();
     _headerPanel.ID = this.HeaderPanelId;
     _headerPanel.Visible = this.Visible;
     _headerPanel.Width = this.Width;
     _headerPanel.Height = this.Height;
     foreach(string key in this.Attributes.Keys)
     {
         string val = this.Attributes[key];
         _headerPanel.Attributes.Add(key, val);
     }
     _headerPanel.ToolTip = this.ToolTip;
     _headerPanel.ApplyStyle(this.ControlStyle);
     // Ensures that if a border is required,
     // the content panel (this) does not get a
     // second border.
     this.BorderStyle = BorderStyle.NotSet;
     // Create the hidden input and set the
     // control collapsed state value.
     _currentState = new HtmlInputHidden();
     _currentState.ID = this.CollapsedStateId;
     _currentState.Value = this.Collapsed ? "true" : "false";
     // Create the control table container.
     _controlTable = new HtmlTable();
     _controlTable.ID = this.ID + "_Table";
     _controlTable.Width = "100%";
     _controlTable.CellSpacing = 0;
     _controlTable.CellPadding = 2;
     _controlTable.Visible = true;
     // Create the header container row.
     _headerRow = new HtmlTableRow();
     _headerRow.ID = this.ID + "_HeaderRow";
     _headerRow.Visible = true;
     // Create the title cell.
     _titleCell = new HtmlTableCell();
     _titleCell.ID = this.ID + "_TitleCell";
     _titleCell.Align = "left";
     _titleCell.Width = "90%";
     _titleCell.Visible = true;
     // Set the style of the cell to the TitleStyle.
     ApplyStyle(_titleCell, this.TitleStyle);
     // Create the title link.
     _titleLink = new HyperLink();
     _titleLink.ID = this.ID + "_TitleLink";
     _titleLink.Text = this.TitleText;
     // Set the style of the link to the TitleStyle.
     _titleLink.ApplyStyle(this.TitleStyle);
     _titleLink.Visible = true;
     // Create the action cell.
     _actionCell = new HtmlTableCell();
     _actionCell.ID = this.ID + "_ActionCell";
     _actionCell.Align = "right";
     _actionCell.Width = "10%";
     _actionCell.Visible = true;
     _actionCell.NoWrap = true;
     // Set the style of the cell to the TitleStyle.
     ApplyStyle(_actionCell, this.TitleStyle);
     // Create the action link.
     _actionLink = new HyperLink();
     _actionLink.ID = this.ID + "_actionLink";
     // Set the style of the link to the TitleStyle.
     _actionLink.ApplyStyle(this.TitleStyle);
     // Create the row container for this control.
     _contentRow = new HtmlTableRow();
     _contentRow.ID = this.ID + "_ContentRow";
     _contentRow.Visible = true;
     // Create the cell container for this control.
     _contentCell = new HtmlTableCell();
     _contentCell.ID = this.ID + "_ContentCell";
     _contentCell.ColSpan = 2;
     _contentCell.Align = "left";
     _contentCell.Visible = true;
     // Set the render method for this control panel.
     // This allows us to render this control (user content panel)
     // as a child of the content cell.
     _contentCell.SetRenderMethodDelegate(
         new RenderMethod(RenderPanelContent));
 }