如何在男性中添加和删除菜单项 [英] How to add and remove the menu items in men

查看:75
本文介绍了如何在男性中添加和删除菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有asp.net导航菜单控件,我想根据用户权限添加和删除菜单项.请让我知道如何实现. 这很紧急.

感谢您的帮助.
PBN.

Hi All,

I have asp.net navigation menu control, I wanted to add and remove the menu items based on the user permissions. Please let me know how it can be achieved. It is very urgent.

Thanks for your help.
PBN.

推荐答案

一点都不急.为您工作的人没有紧迫感.

有内置的ASP.NET菜单控件吗?如果没有,您在使用什么?发布一些代码将有助于我们缩小范围.

有多少种不同的权限组合?您可以用代码动态地构建菜单吗?这就是我的目标,发出菜单代码并检查每个项目是否允许.
It''s not urgent at all. The people doing your job for you, feel no sense of urgency.

Is there an ASP.NET menu control built in ? If not, what are you using ? Posting some code would help us to narrow that down.

How many different combinations of permissions are there ? Can you build the menu dynamically in code ? That''s what I''d aim to do, to emit the menu code and check each item to see if it is allowed.



您可以使用sql表或站点地图根据用户权限和角色来绑定菜单.
试试这个:
http://catalog.codeproject.com/Articles/36641/Binding-Sitemaps-with-Menu-Control-Based-on-User-P [使用C#按需获取升高的特权 [ ^ ]
将菜单和站点地图与母版页一起使用 [ ^ ]
在运行时基于用户权限通过菜单控件绑定站点地图 [ ^ ]


--Amit
Hi,
You can use either your sql table or sitemap to bind the menu based upon the user privilege and roles.
Try this:
http://catalog.codeproject.com/Articles/36641/Binding-Sitemaps-with-Menu-Control-Based-on-User-P[^]
Getting Elevated Privileges on Demand using C#[^]
Using Menu and Sitemap with Master Page[^]
Binding Sitemaps with Menu Control Based on User Privilege at Runtime[^]


--Amit


最近,我开发了一个类似的网站.我使用了站点地图来添加菜单项,并使用LINQ根据用户角色在站点地图中添加或删除节点.如果您知道使用LINQ查询,那将非常容易.

下面的链接将非常有用..
http://www.dotnetcurry.com/ShowArticle.aspx?ID=281 [ ^ ]

取得更多结果.

我在下面使用了代码.

Recently I developed a similar site. I used sitemap to add menu items and LINQ to add or remove the nodes from the sitemap based on user roles. Its quite easy if you know working with LINQ queries.

The links below would be useful try out..
http://www.dotnetcurry.com/ShowArticle.aspx?ID=281[^]

Bing for more results.

I used code below.

string sUserGroup = UserGroup.TrimEnd(';');
string[] arrUserGroup = sUserGroup.Split(';');
//string dummy1 = Server.MapPath("~\\Web.sitemap");
XDocument master = XDocument.Load(Server.MapPath("~\\Web.sitemap"));

XElement xelement = null, xElement = new XElement("siteMap");
xElement.Add(new XElement("siteMapNode", new XAttribute("title", "Home")));
foreach (string s in arrUserGroup)
{
    if (s.Equals("1500") || s.Equals("2500") || s.Equals("3500"))
    {
        //Dont add these---> Will be handled later (Meant for checker transactions)
    }
    else
    {
        System.Diagnostics.Debug.WriteLine("INFO", "Inside FOR-1");
        System.Diagnostics.Debug.WriteLine("INFO", s);

        var v = from e1 in master.Descendants("siteMapNode")
                where e1.Attribute("id").Value == s
                select e1;
        foreach (XElement xe in v)
        {
            System.Diagnostics.Debug.WriteLine("INFO", "Inside FOR-2");
            xelement = new XElement(xe);
        }

        xElement.Element("siteMapNode").Add(xelement);
        xElement.Save(Server.MapPath("~\\Role.sitemap"));
    }
}


这篇关于如何在男性中添加和删除菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆