Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 20th, 2007, 03:14 PM
Registered User
 
Join Date: Nov 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to create progrmmatically Menu tab using XML i

Hello Developer,
I need an urgent help.
I have a xml file that contains some Menu tag like this.
<?xml version="1.0" encoding="utf-8" ?>
<Menu>
<Group Flow="Horizontal">
<Item NavigateUrl="/Home.aspx" Width="53px" Height="22px" ImageUrl="/images/nav_home.gif" ImageOverUrl="/images/nav_home_over.gif" runat="server" >
</Item>
<Item NavigateUrl="/HRTools/EmployeeTools/EmployeeProfile.aspx?view=true" Width="135px"
Height="22px" BackColor="Transparent" ImageUrl="/images/nav_profile.gif" ImageOverUrl="/images/nav_profile_over.gif" runat="server">
<Group>
<Item NavigateUrl="/HRTools/EmployeeTools/EmployeeProfile.aspx?view=true" Text="Personal Information" runat="server" />
<Item NavigateUrl="/HRTools/EmployeeTools/PositionInformation.aspx?view=true" Text="Job Information" runat="server" />
<Item NavigateUrl="/SelfService/MyPay.aspx?view=true" Text="Compensation" runat="server" />
<Item NavigateUrl="/BenefitsAdmin/BenefitsSummary.aspx?view=true" Text="Benefits" runat="server" />

Now I want to read this file in my c# page with the following details.
I have different type of users some of them belongs to Manager label and some of them is Agency. Agency label user should not be able to see the menu that is for Manger label.Can somebody help me about this...

Actually I want two things
One: how to build hierarchical menu systems for web-based applications, and two: how to add security and auditing.

I am using ASP.net and C#.I have an XML file that contains all the menu items we just nned to add security and auditing..
 
Old November 22nd, 2007, 07:56 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

I can get you part way there. I'm a little unsure of how to approach that use of XML, but here's the larger outline of what you're going to do.

ASP.NET has a Membership provider that allows you to assign different security roles to various users. Among others, it sounds like you'll want to assign at least two roles, Agents and Managers. Then you will add a LoginView control to the page, and set it's properties so that only Managers have access to the contents of the LoginView. Then code items available to everyone outside of the LoginView control, and code items available to Managers only inside the LoginView. You can insert as much or as little of the page inside the LoginView, depending on what you want available to Managers only. If the whole menu should be restricted, place the entire menu inside the LoginView. If say, only the 2nd and 5th items on the menu should be restricted to Managers, you would start writing your menu code, then have a LoginView wrapped around the 2nd item, then the 3rd and 4th menu items, then another LoginView wrapped around 5th item.

Now since the menu's being pulled from an XML file this will get more complicated, because your C# code is going to have to grab the menu code and then start processing it to apply the LoginView in places where you want it, and not in the places that you don't. I'm guessing you're going to need a for each loop to go through each of the menu items and see if they are available to everyone or not. This would be where I'm a bit sketchy on the implementation. But that's the general outline of what you want to do. You might want to spend some time with the membership provider. This is just a relatively limited application. You can actually do some much more complicated things using LoginViews and other controls for very advanced designs.

For example, you might want to abandon this whole approach and simply investigate how the Membership provider can allow you to use "security trimming". If you use a sitemap file in your web application which lists the roles that each page is available to, the default navigation tools (SiteMapPath, Menu, etc.) automatically provide the kind of behavior you're looking for. Simply drop the navigation control where you want it in code and specify the sitemap for it to use as a source. Then you'll get rid of the XML document with your menu information and recode that in a *.sitemap file (which is also in XML, it wouldn't be much different than the structure of your current menu).

Just a couple ideas.

-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create tab control in web application vino_gayathri ASP.NET 1.0 and 1.1 Basics 1 February 20th, 2007 05:07 AM
how create menubar, menu, menu item in xsl vijayanmsc XSLT 1 June 5th, 2006 06:43 AM
how can i create menu in JavaScript for client ?? jay4ever_2000 ASP.NET 1.0 and 1.1 Professional 0 February 28th, 2006 08:10 AM
How do I create a jump menu in XSLT? kwilliams XSLT 4 January 9th, 2006 10:34 AM
How do I create a menu in xslt? TrixiePix XSLT 0 December 8th, 2005 11:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.