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


C# WebControls.MenuItem类代码示例

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


MenuItem类属于System.Web.UI.WebControls命名空间,在下文中一共展示了MenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            ShopEntities dbShop = new ShopEntities();

            NavigationMenu.Items[1].ChildItems.Clear();
            foreach (var category in dbShop.Categories)
            {
                var menuItem = new MenuItem(category.Name, category.id.ToString(), "", category.NavigateUrl);
                NavigationMenu.Items[1].ChildItems.Add(menuItem);
            }
        }
开发者ID:Elta20042004,项目名称:YoYo,代码行数:11,代码来源:Site.Master.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            TreeView treeForum;
            Conector con = new Conector();
            /////////////////////////////////////Forum ID->Server ID////////////////////////////////////
            MembershipUser m = Membership.GetUser();
            if (m!=null)
            {
                SqlDataReader is_allrady_Reg = con.select("SELECT   TOP (1)  Server_id_user FROM         IDs_Server_and_Forum WHERE     (Forum_id_user = '" + m.ProviderUserKey.ToString() + "')");
                if (!is_allrady_Reg.Read())
                {
                    int id_server;
                    SqlDataReader id_server_new = con.select("SELECT   TOP (1)  Forum_id_user FROM         IDs_Server_and_Forum ORDER BY Forum_id_user DESC");
                    if (id_server_new.Read())
                    {
                        id_server = Convert.ToInt32(id_server_new[0].ToString());
                    }
                    else
                        id_server = 0;
                    con.insert("INSERT INTO IDs_Server_and_Forum  (Server_id_user, Forum_id_user) VALUES     (" + id_server + ",'" + m.ProviderUserKey.ToString() + "')");
                    con.insert("INSERT INTO Server_info  (ID_Client) VALUES     (" + id_server + ")");
                }
            }

            ////////////////////////////////////////////////////////////////////////////////////////////
            SqlDataReader Forum;
            SqlDataReader SabForum;

            int i = 0;
            Forum = con.select("SELECT id, name FROM forum");
            treeForum = this.TreeView1;
            ContentPlaceHolder menu = (ContentPlaceHolder)Master.FindControl("menu");
            Menu men = (Menu)menu.FindControl("NavigationMenu");
            if (Roles.IsUserInRole("Users") || Roles.IsUserInRole("Admins"))
            {
                MenuItem it = new MenuItem("Создать раздачю");
                it.NavigateUrl= "~/Forum/Create_topic.aspx";
                men.Items.Add(it);
            }

            while (Forum.Read())
            {

                TreeNode t =new TreeNode(Forum[1].ToString());
                t.NavigateUrl="~/Forum/ShowForum.aspx?forum="+Forum[0].ToString();
                treeForum.Nodes.Add(t);
                SabForum = con.select("SELECT     name, id FROM         subforum WHERE     (forum = "+Forum[0].ToString()+")");
                 while(SabForum.Read())
                 {

                    TreeNode t1 = new TreeNode(SabForum[0].ToString());
                     t1.NavigateUrl="~/Forum/ShowSabForum.aspx?forum="+Forum[0].ToString()+"&subforum="+SabForum[1].ToString();
                    treeForum.Nodes[i].ChildNodes.Add(t1);

                }
                 i++;
            }

            con.con_close();
        }
开发者ID:yaroslavchuvaev,项目名称:p2p,代码行数:60,代码来源:Default.aspx.cs

示例3: AddChildMenuItems

        private void AddChildMenuItems(DataTable menuData, MenuItem parentMenuItem)
        {
            DataView view = null;
            try
            {
                view = new DataView(menuData);
                view.RowFilter = "ParentID=" + parentMenuItem.Value;
                foreach (DataRowView row in view)
                {
                    MenuItem newMenuItem = new MenuItem(row["Text"].ToString(), row["MenuID"].ToString());
                    newMenuItem.NavigateUrl = row["NavigateUrl"].ToString();
                    parentMenuItem.ChildItems.Add(newMenuItem);

                    AddChildMenuItems(menuData, newMenuItem);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            finally
            {
                view = null;
            }
        }
开发者ID:jtomaylla,项目名称:gitSEISPY,代码行数:25,代码来源:Site.Master.cs

示例4: IsLink

        private bool IsLink(MenuItem item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            return item.Enabled && !string.IsNullOrEmpty(item.NavigateUrl);
        }
开发者ID:fabriciogs,项目名称:Bootstrap.WebForms.Controls,代码行数:7,代码来源:Menu.cs

示例5: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if(!IsPostBack)
     {
         var categories = (from category in ent.Kategoriler
                           where category.silindi == false
                           select category).ToList();
         foreach (var kategori in categories)
         {
             MenuItem mitm = new MenuItem();
             mitm.Text = kategori.kategoriad;
             mitm.Value = kategori.ID.ToString();
             mnuKategoriler.Items.Add(mitm);
             var subcategories = (from subcategory in ent.AltKategoriler
                               where subcategory.silindi == false && subcategory.kategorino == kategori.ID
                               select subcategory).ToList();
             foreach (var altkategori in subcategories)
             {
                 MenuItem citm = new MenuItem();
                 citm.Text = altkategori.altkategoriad;
                 citm.Value = altkategori.ID.ToString();
                 mitm.ChildItems.Add(citm);
             }
         }
     }
 }
开发者ID:ykeremuzun,项目名称:SaglikUrunleri,代码行数:26,代码来源:Site1.Master.cs

示例6: GenerateHtml

        public string GenerateHtml(string currentUrl, string currentPage,Func<string,string> virtualPathResolver)
        {
            var items = BuildMenu(currentUrl, currentPage);
             StringBuilder menuText = new StringBuilder();
            menuText.Append("<ul>");
            foreach (var item in items)
            {
                var menuitem = new MenuItem()
                                   {
                                       Text = item.Text,
                                       NavigateUrl = item.Url,
                                       Selected = item.Selected
                                   };

                menuText.Append("<li>");
                menuText.AppendFormat("<a href=\"{0}\" ", virtualPathResolver(menuitem.NavigateUrl));
                if (menuitem.Selected)
                {
                    menuText.Append("class=\"selected\"");
                }
                menuText.AppendFormat(">{0}</a></li>", menuitem.Text);
            }
            menuText.Append("</ul>");
            //menuText.Append("<div style=\"float:clear;\"></div>");
               return menuText.ToString();
        }
开发者ID:chrisortman,项目名称:CvDnug,代码行数:26,代码来源:03_MainMenu.cs

示例7: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            ShortMenu = false;
            ShowImg = false;

            // organization
            bool orgVisible = (PanelRequest.ItemID > 0 && Request[DefaultPage.PAGE_ID_PARAM].Equals(PID_SPACE_EXCHANGE_SERVER, StringComparison.InvariantCultureIgnoreCase));

            orgMenu.Visible = orgVisible;

            if (orgVisible)
            {
                MenuItem rootItem = new MenuItem(locMenuTitle.Text);
                rootItem.Selectable = false;

                menu.Items.Add(rootItem);

                //Add "Organization Home" menu item
                MenuItem item = new MenuItem(
                    GetLocalizedString("Text.OrganizationHome"),
                    "",
                    "",
                    PortalUtils.EditUrl("ItemID", PanelRequest.ItemID.ToString(), "organization_home", "SpaceID=" + PanelSecurity.PackageId));

                rootItem.ChildItems.Add(item);

                BindMenu(rootItem.ChildItems);
            }
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:29,代码来源:OrganizationMenu.ascx.cs

示例8: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var Categories = from category in ent.Kategoriler
                          where category.silindi == false
                          select new { category.id, category.kategoriad };
         foreach (var kategori in Categories)
         {
             MenuItem mitm = new MenuItem();
             mitm.Text = kategori.kategoriad;
             mitm.Value = kategori.id.ToString();
             mnuKategoriler.Items.Add(mitm);
             var SubCategories = from subcategory in ent.AltKategoriler
                              where subcategory.silindi == false && subcategory.kategorino == kategori.id
                              select new { subcategory.id, subcategory.altkategoriad };
             foreach (var altkategori in SubCategories)
             {
                 MenuItem citm = new MenuItem();
                 citm.Text = altkategori.altkategoriad;
                 citm.Value = altkategori.id.ToString();
                 mitm.ChildItems.Add(citm);
             }
         }
     }
 }
开发者ID:AlptugYaman,项目名称:SaglikUrunleri,代码行数:26,代码来源:Site1.Master.cs

示例9: llenarMenu

        private void llenarMenu(List<Entidades.MenuXrol> menus, int requiereSesion)
        {
            Entidades.Usuarios us = (Entidades.Usuarios)context.Session["usuario"];
            if (us != null)
            {
                List<Entidades.MenuXrol> menusPadre;
                var consultaPadres = from m in menus
                                     where m.IdMenu.Nodo == 0
                                     where m.IdMenu.Sesion == requiereSesion
                                     orderby m.IdMenu.Orden
                                     select m;
                menusPadre = consultaPadres.ToList();

                menusPadre.ForEach(delegate (Entidades.MenuXrol menu)
                {
                    MenuItem miMenuItem = new MenuItem(menu.IdMenu.Nombre, string.Empty, string.Empty, menu.IdMenu.Url);
                    List<Entidades.MenuXrol> submenus;
                    var consultaSubmenus = from m in menus
                                           where m.IdMenu.Nodo == menu.IdMenu.IdMenu
                                           where m.IdMenu.Sesion == requiereSesion
                                           orderby m.IdMenu.Orden
                                           select m;
                    submenus = consultaSubmenus.ToList();
                    submenus.ForEach(delegate (Entidades.MenuXrol submenu)
                    {
                        MenuItem miMenuItemChild = new MenuItem(submenu.IdMenu.Nombre, string.Empty, string.Empty, submenu.IdMenu.Url);
                        //this.MyMenu.Items.Add(miMenuItemChild);
                        miMenuItem.ChildItems.Add(miMenuItemChild);
                    });
                    this.Menu1.Items.Add(miMenuItem);
                });

            }
        }
开发者ID:prodevelop001,项目名称:ControlServidores,代码行数:34,代码来源:Sitio.Master.cs

示例10: setMenuData

        protected void setMenuData()
        {
            Menu menu = new Menu();
            MenuItem item;

            item = new MenuItem();
            item.Text = "Home Page";
            item.Value = "valueHomePage";
            menu.Items.Add(item);
            item = null;

            item = new MenuItem();
            item.Text = "Contact Us";
            item.Value = "valueContactUs";
            menu.Items.Add(item);
            item = null;

            item = new MenuItem();
            item.Text = "Productions";
            item.Value = "valueProductions";
            menu.Items.Add(item);
            item = null;

            item = new MenuItem();
            item.Text = "Compare";
            item.Value = "valueCompare";
            menu.Items.Add(item);
            item = null;

            item = new MenuItem();
            item.Text = "Links";
            item.Value = "valueLinks";
            menu.Items.Add(item);
            item = null;
        }
开发者ID:salahmyn,项目名称:galileovietnam,代码行数:35,代码来源:LeftMenuControl.ascx.cs

示例11: setMenuItem

        protected void setMenuItem()
        {
            Menu menu = (Menu)this.FindControl("mnuLeft");
            MenuItem item;

            item = new MenuItem();
            item.Text = "MacBook";
            item.Value = "valueMacBook";
            menu.Items.Add(item);
            item = null;

            item = new MenuItem();
            item.Text = "MacBook Pro";
            item.Value = "valueMacBookPro";
            menu.Items.Add(item);
            item = null;

            item = new MenuItem();
            item.Text = "MacBook Air";
            item.Value = "valueMacBookAir";
            menu.Items.Add(item);
            item = null;

            item = new MenuItem();
            item.Text = "Mac mini";
            item.Value = "valueMacMini";
            menu.Items.Add(item);
            item = null;
        }
开发者ID:salahmyn,项目名称:galileovietnam,代码行数:29,代码来源:LeftMenuControl.ascx.cs

示例12: LeftMenuHazirla

        /// <summary>
        /// <remarks>Ana ve alt kategorileri Linq ile alıp Menu ve MenuItem kullanır</remarks>
        /// </summary>
        public void LeftMenuHazirla()
        {
            try
            {
                Models.PoliklinikEntities5 p = new Models.PoliklinikEntities5();
                var res = from c in p.UrunKategori
                          select new { Adi = c.Adi, ID = c.AnaKategoriID };

                foreach (var item in res.ToList())
                {
                    MenuItem Ana = new MenuItem();
                    Ana.Text = item.Adi;
                    Ana.NavigateUrl = @"MainPage.aspx?KatID=" + item.ID.ToString();
                    var res1 = from c in p.UrunKategori
                               join d in p.UrunAltKategori on c.AnaKategoriID equals d.AnaKategori
                               where c.AnaKategoriID == item.ID
                               select new { ID = c.AnaKategoriID, AltKatID = d.AltKategoriID, AltKatAdi = d.Adi };
                    foreach (var altkat in res1.ToList())
                    {
                        MenuItem Alt = new MenuItem();
                        Alt.Text = altkat.AltKatAdi;
                        Alt.NavigateUrl = @"UrunListesi.aspx?KatID=" + item.ID.ToString() + "&AltKatID=" + altkat.AltKatID.ToString();
                        Ana.ChildItems.Add(Alt);
                    }

                    Menu1.Items.Add(Ana);
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
开发者ID:tamerin1,项目名称:e-commerce,代码行数:37,代码来源:default.aspx.cs

示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session.Contents["userid"] != null)
            {
                if (Session.Contents["rol"].ToString().Equals("DSTADM"))
                {
                    MenuItem childItem = new MenuItem();
                    MenuItem childItem2 = new MenuItem();
                    MenuItem childItem3 = new MenuItem();

                    childItem2.Text = "Clientes Existentes";
                    childItem2.NavigateUrl = "../Dst/Solicitud_Dispensadores.aspx";

                    childItem3.Text = "Clientes Nuevos";
                    childItem3.NavigateUrl = "../Dst/Solicitud_Clientes_Nuevos.aspx";

                    childItem.ChildItems.Add(childItem3);
                    childItem.ChildItems.Add(childItem2);
                    childItem.Text = "Solicitud Dispensadores";
                    childItem.Selectable = false;
                    NavigationMenu.Items[1].ChildItems.AddAt(0, childItem);
                    NavigationMenu.Items[1].ChildItems[1].NavigateUrl = "../Dst/SeguimientoSolicitudes.aspx";

                    NavigationMenu.Items[2].ChildItems[0].ChildItems.RemoveAt(1);
                    NavigationMenu.Items[2].ChildItems[0].ChildItems.RemoveAt(0);
                    NavigationMenu.Items[2].ChildItems[1].Text = "Vendedores";
                    NavigationMenu.Items[2].ChildItems.RemoveAt(2);
                    NavigationMenu.Items.RemoveAt(3);
                }
            }
        }
开发者ID:Eliazar,项目名称:Dispenser_Tracking,代码行数:31,代码来源:Mantenimiento.Master.cs

示例14: IsNavHeader

        private bool IsNavHeader(MenuItem item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            return item.ToolTip.Equals("*IsNavHeader*");
        }
开发者ID:fabriciogs,项目名称:Bootstrap.WebForms.Controls,代码行数:7,代码来源:Menu.cs

示例15: HasChildren

        private bool HasChildren(MenuItem item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            return item.ChildItems.Count > 0;
        }
开发者ID:fabriciogs,项目名称:Bootstrap.WebForms.Controls,代码行数:7,代码来源:Menu.cs


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