当前位置: 首页>>代码示例>>C#>>正文


C# HyperLink.ApplyStyle方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.HyperLink.ApplyStyle方法的典型用法代码示例。如果您正苦于以下问题:C# HyperLink.ApplyStyle方法的具体用法?C# HyperLink.ApplyStyle怎么用?C# HyperLink.ApplyStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.HyperLink的用法示例。


在下文中一共展示了HyperLink.ApplyStyle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeItem

        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);
            }
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:80,代码来源:SiteMapPath.cs

示例2: InitializeItem

        /// <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);
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:77,代码来源:SiteMapPath.cs

示例3: CreateControlComponents

 /// <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));
 }
开发者ID:habeebtc,项目名称:Spam,代码行数:94,代码来源:DataPanel.cs


注:本文中的System.Web.UI.WebControls.HyperLink.ApplyStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。