本文整理汇总了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);
}
}
示例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();
}
示例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;
}
}
示例4: IsLink
private bool IsLink(MenuItem item)
{
if (item == null)
throw new ArgumentNullException("item");
return item.Enabled && !string.IsNullOrEmpty(item.NavigateUrl);
}
示例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);
}
}
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
});
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
示例14: IsNavHeader
private bool IsNavHeader(MenuItem item)
{
if (item == null)
throw new ArgumentNullException("item");
return item.ToolTip.Equals("*IsNavHeader*");
}
示例15: HasChildren
private bool HasChildren(MenuItem item)
{
if (item == null)
throw new ArgumentNullException("item");
return item.ChildItems.Count > 0;
}