Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
  #1 (permalink)  
Old September 25th, 2006, 11:25 PM
Authorized User
 
Join Date: Jan 2006
Location: Hunza, Gilgit, Northern Areas, Pakistan.
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hunzian78@yahoo.com
Default Most Important Problem! Plz Help

Hi all

I got a tricky problem...

I have a menu and put some menu items through menu item editor and those items are sticked to respective pages using NavigateUrl property. I have created some roles i.e. administrators and users for accessing and updating my application. I have also defined some rules to access those menu items.

Suppose follwoing is the menu and its menu items

-admin
    *add user
    *view user
-school
    *add school
    *view school

I want to remain add school menu item invisible when a non administrator visists there ... I did the same keeping the SiteMap as the data source for the menu control and modifying the web.config(securityTrimmingEnabled = "true" )file.



I hope you understood the whole scenario ....

Abdul Ghaffar

  #2 (permalink)  
Old September 25th, 2006, 11:52 PM
Friend of Wrox
 
Join Date: Feb 2006
Location: , , USA.
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Abdul,

What you need to do is detect the role of the logged in user in the code behind, probably in the page_load event (though there are other events you could handle).

In that page_load event handler, you can set the menu items programmaticaly there after you detect what role the logged in person is a member of. By programmiticaly setting the menu items, you will insure only the correct menu items are available.

Here's an example of how to add an item to a Menu control:

Code:
mnPrimaryNav.Items(0).ChildItems.Add(New MenuItem("Display Text", "", "", "http://pagetolinkto.aspx/")
Neil Timmerman
Programmer
Veris Consulting
  #3 (permalink)  
Old September 26th, 2006, 01:42 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Agreed. The secnario that Neil described is exactly the way that I handle my entire Menu system throughout my intranet; the only difference being I do not assign permissions to users, I assign permissions to Roles (and users belong to roles). I find this to be alot easier to manage then dealing with each individual user.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
  #4 (permalink)  
Old September 28th, 2006, 01:43 AM
Authorized User
 
Join Date: Jan 2006
Location: Hunza, Gilgit, Northern Areas, Pakistan.
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hunzian78@yahoo.com
Default

Hi ...

Thank you very very much Neil & Parson ... I finally did what i wished to ... actually i used a masterpage and on page_load event handler of that page I programatically added the menu items according to roles which I have given to various users.

Once again thank you very much for your valuable replies...

Abdul Ghaffar


Similar Threads
Thread Thread Starter Forum Replies Last Post
plz.....plz solve out my problem.... kethireddy435 ASP.NET 1.x and 2.0 Application Design 1 October 4th, 2007 12:56 PM
plz solve my problem mkazim85 SQL Language 2 May 14th, 2007 05:31 AM
An important problem ajabbabahalmigiriha C# 1 February 17th, 2007 03:42 PM
Excel Problem Very Important elghoul_girl ASP.NET 1.0 and 1.1 Basics 1 November 20th, 2005 11:32 PM





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