本文整理汇总了C#中System.Web.UI.WebControls.MenuItemCollection类的典型用法代码示例。如果您正苦于以下问题:C# MenuItemCollection类的具体用法?C# MenuItemCollection怎么用?C# MenuItemCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MenuItemCollection类属于System.Web.UI.WebControls命名空间,在下文中一共展示了MenuItemCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeluxeMenu
/// <summary>
/// PopupMenu构造函数
/// </summary>
/// <remarks></remarks>
public DeluxeMenu()
: base(true, HtmlTextWriterTag.Div)
{
this.items = new MenuItemCollection(null);
//this.Style.Add("Width", "0");
}
示例2: BuildItems
private void BuildItems(HtmlTextWriter writer, MenuItemCollection items, bool isRoot = false)
{
if (items.Count <= 0)
{
return;
}
string cssClass = "submenu";
if (isRoot)
{
cssClass = "nav sidebar-menu";
if (!string.IsNullOrEmpty(this.CssClass))
{
cssClass += " " + this.CssClass;
}
}
writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
writer.RenderBeginTag(HtmlTextWriterTag.Ul);
if (isRoot)
items = items[0].ChildItems;
foreach (MenuItem item in items)
{
this.BuildItem(writer, item);
}
writer.RenderEndTag(); // </ul>
}
示例3: FindSelectedItem
MenuItem FindSelectedItem(MenuItemCollection items)
{
foreach (MenuItem item in items)
{
if (item.NavigateUrl.Length > 0 && Request.Path.Contains(item.NavigateUrl.Replace("~", "")))
{
return item;
}
MenuItem childSelected = FindSelectedItem(item.ChildItems);
if (childSelected != null)
return childSelected;
}
return null;
}
示例4: BindMenu
public void BindMenu(MenuItemCollection items)
{
if ((PackageId <= 0) || (ItemID <= 0))
return;
//Organization menu group;
if (Cntx.Groups.ContainsKey(ResourceGroups.HostedOrganizations))
PrepareOrganizationMenuRoot(items);
//Exchange menu group;
if (Cntx.Groups.ContainsKey(ResourceGroups.Exchange))
PrepareExchangeMenuRoot(items);
//BlackBerry Menu
if (Cntx.Groups.ContainsKey(ResourceGroups.BlackBerry))
PrepareBlackBerryMenuRoot(items);
//SharePoint menu group;
if (Cntx.Groups.ContainsKey(ResourceGroups.SharepointFoundationServer))
PrepareSharePointMenuRoot(items);
if (Cntx.Groups.ContainsKey(ResourceGroups.SharepointEnterpriseServer))
PrepareSharePointEnterpriseMenuRoot(items);
//CRM Menu
if (Cntx.Groups.ContainsKey(ResourceGroups.HostedCRM2013))
PrepareCRM2013MenuRoot(items);
else if (Cntx.Groups.ContainsKey(ResourceGroups.HostedCRM))
PrepareCRMMenuRoot(items);
//OCS Menu
if (Cntx.Groups.ContainsKey(ResourceGroups.OCS))
PrepareOCSMenuRoot(items);
//Lync Menu
if (Cntx.Groups.ContainsKey(ResourceGroups.Lync))
PrepareLyncMenuRoot(items);
//EnterpriseStorage Menu
if (Cntx.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
PrepareEnterpriseStorageMenuRoot(items);
//Remote Desktop Services Menu
if (Cntx.Groups.ContainsKey(ResourceGroups.RDS))
PrepareRDSMenuRoot(items);
}
示例5: PopulateNodes
private void PopulateNodes(DataTable dt, MenuItemCollection items)
{
foreach (DataRow dr in dt.Rows)
{
MenuItem mi = new MenuItem();
mi.Text = dr["menu"].ToString();
mi.Value = dr["menuid"].ToString();
mi.NavigateUrl = dr["url"].ToString();
items.Add(mi);
//If node has child nodes, then enable on-demand populating
bool flag = ((int)(dr["childnodecount"]) > 0);
if (flag)
{
menuCreate(mi);
}
}
}
示例6: QuitarItems
private void QuitarItems(MenuItemCollection items)
{
MenuItem[] itemsToRemove = new MenuItem[items.Count];
int i = 0;
if (UsuarioLogueado.TipoPersona == Persona.TiposPersonas.Alumno)
{
foreach (MenuItem item in items)
{
if((item.Value=="Alumno") || (item.Value=="Ambos"))
{
if (item.ChildItems.Count > 0) QuitarItems(item.ChildItems);
}
else
{
itemsToRemove[i] = item;
i++;
}
}
for (int j = 0; j < i; j++)
{
items.Remove(itemsToRemove[j]);
}
}
if (UsuarioLogueado.TipoPersona == Persona.TiposPersonas.Docente)
{
foreach (MenuItem item in items)
{
if ((item.Value == "Profesor") || (item.Value == "Ambos"))
{
if (item.ChildItems.Count > 0) QuitarItems(item.ChildItems);
}
else
{
itemsToRemove[i] = item;
i++;
}
}
for (int j = 0; j < i; j++)
{
items.Remove(itemsToRemove[j]);
}
}
}
示例7: RemovePermissaoMenu
public void RemovePermissaoMenu(MenuItemCollection items)
{
ISeguranca iseguranca = Factory.GetInstance<ISeguranca>();
IList<int> indices = new List<int>();
for (int i = items.Count - 1; i >= 0; i--)
{
if (items[i].ChildItems.Count > 0)
{
RemovePermissaoMenu(items[i].ChildItems);
}
if (items[i].Value != "EMPTY" && !iseguranca.VerificarPermissao(((ViverMais.Model.Usuario)Session["Usuario"]).Codigo, items[i].Value.Split(':')[0].ToString(), int.Parse(items[i].Value.Split(':')[1].ToString())))
{
indices.Add(i);
}
}
foreach (int i in indices)
{
items.RemoveAt(i);
}
}
示例8: RenderDropDownMenu
protected void RenderDropDownMenu(HtmlTextWriter writer, MenuItemCollection items, string submenuClientId)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute");
DynamicMenuStyle.AddAttributesToRender(writer);
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Id, submenuClientId);
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
for (int i = 0; i < items.Count; i++)
{
var childItem = items[i];
RenderDropDownMenuItem(writer, childItem, submenuClientId, i);
}
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
}
示例9: BuildItems
private void BuildItems(MenuItemCollection items, bool isRoot, HtmlTextWriter writer)
{
if (items.Count > 0)
{
writer.WriteLine();
writer.WriteBeginTag("ul");
if (isRoot)
{
writer.WriteAttribute("class", "navig twolevel");
}
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
foreach (MenuItem item in items)
{
BuildItem(item, writer);
}
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("ul");
}
}
示例10: MenuItemCollectionEnumerator
internal MenuItemCollectionEnumerator(MenuItemCollection list) {
this.list = list;
this.index = -1;
version = list._version;
}
示例11: RenderMenuBody
void RenderMenuBody (HtmlTextWriter writer, MenuItemCollection items, bool vertical, bool dynamic)
{
if (!vertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr);
for (int n=0; n<items.Count; n++) {
MenuItem item = items [n];
if (n > 0) {
Unit itemSpacing = GetItemSpacing (item, dynamic);
if (itemSpacing != Unit.Empty) {
if (vertical) {
writer.AddAttribute ("height", itemSpacing.ToString());
writer.RenderBeginTag (HtmlTextWriterTag.Tr);
writer.RenderEndTag ();
} else {
writer.AddAttribute ("width", itemSpacing.ToString());
writer.RenderBeginTag (HtmlTextWriterTag.Td);
writer.RenderEndTag ();
}
}
}
RenderMenuItem (writer, item);
}
if (!vertical) writer.RenderEndTag (); // TR
}
示例12: RenderMenu
void RenderMenu (HtmlTextWriter writer, MenuItemCollection items, bool vertical, bool dynamic, int menuLevel)
{
RenderMenuBeginTag (writer, dynamic, menuLevel);
RenderMenuBody (writer, items, vertical, dynamic);
RenderMenuEndTag (writer);
}
示例13: LoadNavigation
/// <summary>
/// Loops through the list items in the MyNiem List and gets the navigation based on access.
/// </summary>
/// <param name="List"></param>
protected void LoadNavigation(SPList List)
{
try
{
if (Page.User.Identity.IsAuthenticated)
{
SPListItemCollection Items = List.Items;
var PersonalNav = LoginView1.FindControl("PersonalNav") as AspMenu;
MenuItemCollection MenuItems = new MenuItemCollection();
//grabs the items in the list then loops through the webs the user currently has access too
foreach (SPListItem Item in Items)
{
//old code to recursively check if the user has access to the subweb
//if (Web.Url.ToLower() == SPContext.Current.Web.Site.RootWeb.Url.ToLower() + "/" + Item["Title"].ToString().ToLower())
// FoundWeb = true;
//else
// FoundWeb = GetSubWebs(Web, SPContext.Current.Web.Site.RootWeb.Url.ToLower() + "/" + Item["Title"].ToString().ToLower(), FoundWeb);
//Guid SiteGuid = SPContext.Current.Site.ID;
string SiteURL = SPContext.Current.Web.Site.RootWeb.Url.ToLower();
SPUser CurrentUser = SPContext.Current.Web.CurrentUser;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
#region OldCode
// if (FoundWeb)
// {
// using (SPSite Site = new SPSite(SPContext.Current.Web.Site.RootWeb.Url.ToLower() + "/" + Item["Title"].ToString()))
// {
// using (SPWeb FoundSubWeb = Site.OpenWeb())
// {
// MenuItem MyNiemItem = new MenuItem(FoundSubWeb.Title, FoundSubWeb.Title, "", FoundSubWeb.Url);
// int CompareNumber = 0;
// for(int i=0;i<MenuItems.Count && CompareNumber>=0;i++)
// {
// string CompareItem = MyNiemItem.Text;
// CompareNumber = CompareItem.CompareTo(MenuItems[i].Text);
// if(CompareNumber < 0)
// MenuItems.AddAt(i, MyNiemItem);
// }
// if(CompareNumber>=0)
// MenuItems.Add(MyNiemItem);
// FoundWeb = false;
// }
// }
// }
//}
//foreach (MenuItem Item in MenuItems)
//{
// PersonalNav.Items.Add(Item);
//}
#endregion
//new code to check against site
using (SPSite Site = new SPSite(SiteURL + "/" + Item["Title"].ToString()))
{
using (SPWeb Web = Site.OpenWeb())
{
if (Web.DoesUserHavePermissions(CurrentUser.LoginName, SPBasePermissions.Open))
{
MenuItem MyNiemItem = new MenuItem(Web.Title, Web.Title, "", Web.Url);
int CompareNumber = 0;
for (int i = 0; i < MenuItems.Count && CompareNumber >= 0; i++)
{
string CompareItem = MyNiemItem.Text;
CompareNumber = CompareItem.CompareTo(MenuItems[i].Text);
if (CompareNumber < 0)
MenuItems.AddAt(i, MyNiemItem);
}
if (CompareNumber >= 0)
MenuItems.Add(MyNiemItem);
}
}
}
});
}
foreach (MenuItem Item in MenuItems)
{
PersonalNav.Items.Add(Item);
}
}
}
catch (SPException ex)
{
UpdateErrorLog(ex);
}
}
示例14: BuildItems
private void BuildItems(MenuItemCollection items, bool isRoot, HtmlTextWriter writer)
{
if (items.Count > 0)
{
writer.WriteLine();
writer.WriteBeginTag("ul");
if (isRoot)
{
if (!string.IsNullOrEmpty(Control.CssClass))
{
writer.WriteAttribute("class", Control.CssClass);
}
if (Control.ID != "SubNavMenu")
{
writer.WriteAttribute("id", Control.ID);
}
}
else if (_nextingLevel < Control.StaticDisplayLevels)
{
writer.WriteAttribute("style", "position: relative !important; visibility: visible !important;");
}
else if (items[0].Parent.Text == "Contact Us")
{
writer.WriteAttribute("style", "width: 128px !important;");
}
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
foreach (MenuItem item in items)
{
BuildItem(item, writer);
}
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("ul");
}
}
示例15: GetIconsDataSource
public MenuItemCollection GetIconsDataSource(int packageId)
{
// load package context
PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);
// init collection
MenuItemCollection items = new MenuItemCollection();
// get icons list
foreach (XmlNode xmlNode in xmlIcons)
{
// create icon item
MenuItem iconItem = CreateMenuItem(cntx, xmlNode);
if (iconItem == null)
continue;
// add into list
items.Add(iconItem);
}
return items;
}