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


C# MenuItemCollection.Clear方法代碼示例

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


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

示例1: setMenuItemChild

 private void setMenuItemChild(MenuItemCollection mic, params MenuInfo[] menuItems)
 {
     try
     {
         mic.Clear();
         foreach (MenuInfo menuItem in menuItems)
         {
             if (menuItem.Text != "-")
             {
                 MenuItem mi = new MenuItem(menuItem.Text, menuItem.Text);
                 mi.Enabled = menuItem.Enabled;
                 if (
                     String.IsNullOrEmpty(menuItem.NavigateUrl)
                     && menuItem.Text != "Storage connection"
                     && menuItem.Text != "Refresh"
                     && menuItem.SubMenus.Count == 0
                     )
                 {
                     mi.NavigateUrl = String.Format("javascript:openDialog('ModalDialogHandler.aspx?MenuItem={0}&MenuValue={1}');", mi.Text, mi.Value);
                 }
                 else if (!String.IsNullOrEmpty(menuItem.NavigateUrl))
                 {
                     mi.NavigateUrl = menuItem.NavigateUrl;
                     if (!mi.NavigateUrl.StartsWith("javascript:", StringComparison.CurrentCultureIgnoreCase))
                         mi.Target = "_blank";
                 }
                 mi.ToolTip = menuItem.ToolTip;
                 switch (menuItem.Text)
                 {
                     case "Storage connection": mi.ImageUrl = this.getImageUrl("db.gif"); break;
                     case "Options": mi.ImageUrl = this.getImageUrl("Options_16x16.gif"); break;
                     case "Invalidate WCF Cache Service": mi.ImageUrl = this.getImageUrl("Cache_16x16.gif"); break;
                     case "New Store":
                     case "New Application":
                     case "New Store Group":
                     case "New Application Group":
                     case "New Role":
                     case "New Task":
                     case "New Operation":
                         mi.ImageUrl = this.getImageUrl("new.gif"); break;
                     case "Import Store from AzMan":
                         mi.ImageUrl = this.getImageUrl("azman.gif"); break;
                     case "Import Stores":
                     case "Import Store Groups/Application":
                     case "Import Application Groups/Items":
                     case "Import Store Groups":
                     case "Import Application Groups":
                     case "Import Items":
                         mi.ImageUrl = this.getImageUrl("import.gif"); break;
                     case "Export Stores":
                     case "Export Store":
                     case "Export Application":
                     case "Export Store Group":
                     case "Export Application Group":
                     case "Export Items":
                         mi.ImageUrl = this.getImageUrl("export.gif"); break;
                     case "Refresh": mi.ImageUrl = this.getImageUrl("refresh.gif"); break;
                     case "Store Properties": mi.ImageUrl = this.getImageUrl("Store_16x16.gif"); break;
                     case "Items Hierarchical View":
                     case "Items Hierarchy":
                         mi.ImageUrl = this.getImageUrl("Hierarchy_16x16.gif"); break;
                     case "Reports": mi.ImageUrl = this.getImageUrl("print.gif"); break;
                     case "Delete": mi.ImageUrl = this.getImageUrl("delete.gif"); break;
                     case "Items Authorizations": mi.ImageUrl = this.getImageUrl("ItemAuthorization_16x16.gif"); break;
                     case "Mode and Logging": mi.ImageUrl = this.getImageUrl("NetSqlAzMan_16x16.gif"); break;
                     case "Auditing": mi.ImageUrl = this.getImageUrl("SqlAudit_16x16.gif"); break;
                     case "Application Properties": mi.ImageUrl = this.getImageUrl("Application_16x16.gif"); break;
                     case "Generate CheckAccessHelper": mi.ImageUrl = this.getImageUrl("vsnet_16x16.gif"); break;
                     case "Check Access Test": mi.ImageUrl = this.getImageUrl("CheckAccessTest_16x16.gif"); break;
                     case "Application Group Properties":
                     case "Store Group Properties": mi.ImageUrl = this.getImageUrl("StoreApplicationGroup_16x16.gif"); break;
                     case "Role Properties": mi.ImageUrl = this.getImageUrl("Role_16x16.gif"); break;
                     case "Task Properties": mi.ImageUrl = this.getImageUrl("Task_16x16.gif"); break;
                     case "Operation Properties": mi.ImageUrl = this.getImageUrl("Operation_16x16.gif"); break;
                     case "Effective Permissions": mi.ImageUrl = this.getImageUrl("EffectivePermissions_16x16.gif"); break;
                     case "Manage Authorizations": mi.ImageUrl = this.getImageUrl("ItemAuthorization_16x16.gif"); break;
                     default: mi.ImageUrl = this.getImageUrl("blank.gif"); break;
                 }
                 mic.Add(mi);
                 this.setMenuItemChild(mi.ChildItems, menuItem.SubMenus.ToArray());
             }
             else
             {
                 mic[mic.Count - 1].SeparatorImageUrl = "Images/Separator.jpg";
             }
         }
     }
     catch (Exception ex)
     {
         this.ShowError(ex.Message);
     }
 }
開發者ID:JamesTryand,項目名稱:NetSqlAzMan,代碼行數:92,代碼來源:WebConsole.aspx.cs


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