本文整理汇总了C#中System.Web.UI.WebControls.Menu.FindItem方法的典型用法代码示例。如果您正苦于以下问题:C# Menu.FindItem方法的具体用法?C# Menu.FindItem怎么用?C# Menu.FindItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.Menu
的用法示例。
在下文中一共展示了Menu.FindItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetearOpcionesConsultor
private void SetearOpcionesConsultor(Menu menuPrincipal)
{
SetearOpcionesGeneral(menuPrincipal);
menuPrincipal.Items.Remove(menuPrincipal.FindItem("Cliente"));
// Buscar el item Vehiculo
MenuItem menuVehiculo = menuPrincipal.FindItem("Vehiculo");
// Buscar cada subitem del item Vehiculo
MenuItem venderVehiculo = menuPrincipal.FindItem("Vehiculo/VenderVehiculo");
MenuItem registrarVehiculo = menuPrincipal.FindItem("Vehiculo/RegistrarVehiculo");
MenuItem modificarVehiculo = menuPrincipal.FindItem("Vehiculo/ModificarVehiculo");
MenuItem caracteristicasVehiculo = menuPrincipal.FindItem("Vehiculo/CaracteristicasVehiculo");
MenuItem eliminarVehiculo = menuPrincipal.FindItem("Vehiculo/EliminarVehiculo");
// Eliminar cada subitem del item Vehiculo
menuVehiculo.ChildItems.Remove(venderVehiculo);
menuVehiculo.ChildItems.Remove(registrarVehiculo);
menuVehiculo.ChildItems.Remove(modificarVehiculo);
menuVehiculo.ChildItems.Remove(caracteristicasVehiculo);
menuVehiculo.ChildItems.Remove(eliminarVehiculo);
}
示例2: SetearOpcionesGeneral
private void SetearOpcionesGeneral(Menu menuPrincipal)
{
// Remover los items que no son accesibles por el usuario
menuPrincipal.Items.Remove(menuPrincipal.FindItem("Empleado"));
menuPrincipal.Items.Remove(menuPrincipal.FindItem("Comision"));
}
示例3: DoMenuSelection
private void DoMenuSelection(Menu menu)
{
// TODO: clean up this hairy mess without breaking anything
MenuItem menuItem = null;
bool didSelect = false;
string valuePath;
if (isSubMenu)
{
valuePath = SiteUtils.GetPageMenuActivePageValuePath(pageMapDataSource.Provider.RootNode);
}
else
{
valuePath = SiteUtils.GetActivePageValuePath(pageMapDataSource.Provider.RootNode, startingNodeOffset, Request.RawUrl);
}
if (valuePath.Length > 0)
{
menuItem = menu.FindItem(valuePath);
if (menuItem == null)
{
if (startingNodeOffset > 0)
{
for (int i = 1; i <= startingNodeOffset; i++)
{
if (valuePath.IndexOf("|") > -1)
{
valuePath = valuePath.Remove(0, valuePath.IndexOf("|") + 1);
}
}
}
}
if (menuItem == null)
{
valuePath = SiteUtils.GetPageMenuActivePageValuePath(pageMapDataSource.Provider.RootNode);
menuItem = menu.FindItem(valuePath);
}
if (menuItem != null)
{
try
{
menuItem.Selected = true;
didSelect = true;
}
catch (InvalidOperationException)
{
//can happen if node disabled or unselectable
}
}
}
if (!didSelect)
{
valuePath = SiteUtils.GetActivePageValuePath(pageMapDataSource.Provider.RootNode, startingNodeOffset);
if (valuePath.Length > 0)
{
menuItem = menu.FindItem(valuePath);
if (
(menuItem == null)
&& (valuePath.IndexOf(menu.PathSeparator) > -1)
)
{
valuePath = valuePath.Substring(0, (valuePath.IndexOf(menu.PathSeparator)));
menuItem = menu.FindItem(valuePath);
}
if (
(dynamicDisplayLevels == 0)
&& (menuItem == null)
&& (valuePath.IndexOf(menu.PathSeparator) > -1)
)
{
foreach (MenuItem m in menu.Items)
{
if (valuePath.Contains(m.ValuePath))
{
try
{
m.Selected = true;
didSelect = true;
}
catch (InvalidOperationException)
{
//can happen if node disabled or unselectable
}
return;
}
}
}
//.........这里部分代码省略.........
示例4: DoSelecetion
private void DoSelecetion(Menu menu)
{
if (suppressPageSelection) { return; }
bool didSelect = false;
String valuePath = SiteUtils.GetActivePageValuePath(siteMapDataSource.Provider.RootNode, startingNodeOffset, Request.RawUrl);
if (valuePath.Length > 0)
{
MenuItem menuItem;
menuItem = menu.FindItem(valuePath);
if (
(topLevelOnly || menu.MaximumDynamicDisplayLevels == 0)
&& (menuItem == null)
&& (valuePath.IndexOf(menu.PathSeparator) > -1)
)
{
valuePath = valuePath.Substring(0, (valuePath.IndexOf(menu.PathSeparator)));
menuItem = menu.FindItem(valuePath);
}
if (menuItem != null)
{
try
{
menuItem.Selected = true;
didSelect = true;
}
catch (InvalidOperationException)
{
//can happen if node disabled or unselectable
}
}
}
if (!didSelect)
{
valuePath = SiteUtils.GetActivePageValuePath(siteMapDataSource.Provider.RootNode, startingNodeOffset);
if (valuePath.Length > 0)
{
MenuItem menuItem;
menuItem = menu.FindItem(valuePath);
if (
(topLevelOnly)
&& (menuItem == null)
&& (valuePath.IndexOf(menu.PathSeparator) > -1)
)
{
valuePath = valuePath.Substring(0, (valuePath.IndexOf(menu.PathSeparator)));
menuItem = menu.FindItem(valuePath);
// http://www.mojoportal.com/Forums/Thread.aspx?thread=7277&mid=34&pageid=5&ItemID=5&pagenumber=1#post33725
// patch by vijaykarla 2011-05-24
// If the page is not Included In Menu, the above line of code wont work (returns null), following code is solution for it
//=========
if (menuItem == null)
{
#if NET35
if (!string.IsNullOrEmpty(valuePath))
#else
if (!string.IsNullOrWhiteSpace(valuePath))
#endif
{
int lastSeperatorIndex = valuePath.LastIndexOf(menu.PathSeparator);
while (lastSeperatorIndex > 0)
{
valuePath = valuePath.Substring(0, lastSeperatorIndex);
menuItem = menu.FindItem(valuePath);
if (menuItem != null)
break;
lastSeperatorIndex = valuePath.LastIndexOf(menu.PathSeparator);
}
}
}
//=======
}
if (menuItem != null)
{
try
{
menuItem.Selected = true;
didSelect = true;
}
catch (InvalidOperationException)
{
//can happen if node disabled or unselectable
}
}
}
}
}
示例5: RemoverMenuItem
public static void RemoverMenuItem(Menu Menu, string IdMenuItem)
{
MenuItem menuItem = Menu.FindItem(IdMenuItem);
if (menuItem != null) RemoverMenuItem(Menu, menuItem);
}