I was recently tasked with creating a menu system that was dynamic depending on the user's security level. For example, a user that was part of an Administrator group would be able to see a menu item for the Administrator pages. User's who were not part of the Administrator group would not be able to see this menu.

So I decided to use the ASP.Net Menu and use an XML Datasource as it's datasource.

// This method checks against a database field to determine if user
// is an Admin
// You could also integrate with Active Directory to see if user
// is part of a specific AD user group
// The Session "OperatorID" is stored from a login page
protected string GetRole()
{
string role = string.Empty;
int operatorID = 0;
operatorID = int.Parse(Session["OperatorID"].ToString());
if (OperatorManager.IsOperatorAdmin(operatorID))
role = "Admin";
else
role = "User";
return role;
}

And that's it.

Now the benefit of this is that you can change the menus that users will see by simply editing the xml files(assuming the .aspx pages are already created). For example, if I wanted all users to see the Admin menu, I would simply change the xml file on the web server. No need to build and publish the site again.

Replies To: ASP.Net Menu with XML DataSource

I was recently tasked with creating a menu system that was dynamic depending on the user's security level. For example, a user that was part of an Administrator group would be able to see a menu item for the Administrator pages. User's who were not part of the Administrator group would not be able to see this menu.

So I decided to use the ASP.Net Menu and use an XML Datasource as it's datasource.

// This method checks against a database field to determine if user
// is an Admin
// You could also integrate with Active Directory to see if user
// is part of a specific AD user group
// The Session "OperatorID" is stored from a login page
protected string GetRole()
{
string role = string.Empty;
int operatorID = 0;
operatorID = int.Parse(Session["OperatorID"].ToString());
if (OperatorManager.IsOperatorAdmin(operatorID))
role = "Admin";
else
role = "User";
return role;
}

And that's it.

Now the benefit of this is that you can change the menus that users will see by simply editing the xml files(assuming the .aspx pages are already created). For example, if I wanted all users to see the Admin menu, I would simply change the xml file on the web server. No need to build and publish the site again.

Hi,

I have tried to create a sample application as you said in the post but i am not able to bind the menu items from the correct xml to the menu control, I am able to get the path of the required xml but @/Items/Item not able to bind any data with the menu control.
Should i have to folow any other way or i have to add any extra code segment?