當前位置: 首頁>>代碼示例>>C#>>正文


C# PlaceHolder.Dispose方法代碼示例

本文整理匯總了C#中System.Web.UI.WebControls.PlaceHolder.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# PlaceHolder.Dispose方法的具體用法?C# PlaceHolder.Dispose怎麽用?C# PlaceHolder.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.UI.WebControls.PlaceHolder的用法示例。


在下文中一共展示了PlaceHolder.Dispose方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RenderNode

        private void RenderNode(PlaceHolder placeHolder, SiteMapNode node, int level)
        {
            //<section>
            //   <h3><a href="#" class="nav-current">Current section (4) example </a></h3>
            //   <ul>
            //       <li><a href="#">Item 4a</a></li>
            //       <li><a href="#" class="nav-current">Current item (4b) example</a>
            //           <ul>
            //               <li><a href="#">Item 4bi</a></li>
            //               <li><a href="#" class="nav-current">Current sub (4bii) item example</a></li>
            //               <li><a href="#">Item 4biii</a></li>
            //           </ul>
            //       </li>
            //       <li><a href="#">Item 4c</a></li>
            //   </ul>
            //</section>
            if (!ShowNode(node, level))
            {
                return;
            }

            string cssClass = GetCssClass(node, level);
            String cssClassHtml = String.Empty;
            if (!String.IsNullOrEmpty(cssClass))
            {
                cssClassHtml = String.Format(" class=\"{0}\"", cssClass);
            }

            // figure out the wrapper that you want to put around the Node depending on the level
            // handle the section headers
            if (level == 0)
            {
                // add the "<section><h3>"
                placeHolder.Controls.Add(new LiteralControl(SectionOpenHTML + SectionHeaderOpenHtml));
            }
            else
            {
                // render a "<LI>" for the item
                placeHolder.Controls.Add(new LiteralControl(String.Format(ListItemOpenHtml, cssClassHtml)));
            }

            // Render the link for the item or title
            RenderNodeItem(placeHolder, node, cssClass);

            // render any closing elements for the level
            if (level == 0)
            {
                placeHolder.Controls.Add(new LiteralControl(SectionHeaderCloseHtml));
            }

            // render any expandable child items
            if (IsNodeExpandable(node, level))
            {
                SiteMapNodeCollection nodes = _provider.GetChildNodes(node);
                PlaceHolder childrenPlaceHolder = new PlaceHolder();

                foreach (SiteMapNode childrenNode in nodes)
                {
                    RenderNode(childrenPlaceHolder, childrenNode, level + 1);
                }

                if (childrenPlaceHolder.Controls.Count > 0)
                {
                    String subListCssClass = String.Empty;
                    placeHolder.Controls.Add(new LiteralControl(ListOpenHtml));
                    placeHolder.Controls.Add(childrenPlaceHolder);
                    placeHolder.Controls.Add(new LiteralControl(ListCloseHtml));
                }
                else
                {
                    childrenPlaceHolder.Dispose();
                }
            }

            // render any closing elements for the 0 level section or the child list item
            if (level == 0)
            {
                placeHolder.Controls.Add(new LiteralControl(SectionCloseHTML));
            }
            else
            {
                placeHolder.Controls.Add(new LiteralControl(ListItemCloseHtml));
            }
        }
開發者ID:nschonni,項目名稱:wet-boew-sharepoint,代碼行數:84,代碼來源:LeftNavigation.cs


注:本文中的System.Web.UI.WebControls.PlaceHolder.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。