CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.club_web_site_starter_kit Tags:
Item Type: NewsGroup Date Entered: 8/13/2007 2:37:08 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 40 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
CRONER
Asp.Net User
Adding Roles that can update caledar, news, photos etc...8/13/2007 2:37:08 AM

0

Which is the correct way to add the roles to the code (not to the database; lets say these already are created, and user log in works fine)

No 1 (from Events_Calendar.aspx)

protected void Page_Load(object sender, System.EventArgs e)

{

bool isAdmin = User.IsInRole("Administrators");bool isGeneral = User.IsInRole("General");

panel1.Visible = isAdmin;

panel2.Visible = isAdmin;

panel1.Visible = isGeneral;

panel2.Visible = isGeneral;

}

------- You see I just added another bool "General" --------------

or do I have to add something like this, and in how many instances, which pages need same code mods?

private bool isGeneral()

{

bool isGeneral = User.IsInRole("General");return isGeneral;

}

-------------Here I added this to the botom of the same page - ----------

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

I also made these mods to the Events_List.... would this be ok??

private bool IsAdmin;

private bool IsGeneral;

protected void Page_Load(object sender, System.EventArgs e)

{

IsAdmin = User.IsInRole(
"Administrators");IsGeneral = User.IsInRole("General");

panel1.Visible = IsAdmin;

panel1.Visible = IsGeneral;

}

Similar mods to all the "list" pages...

So is this correct way to add another role that can be used for editing/uploadnig news, events, calendar etc... and if not what is?


CRONER
johram
Asp.Net User
Re: Adding Roles that can update caledar, news, photos etc...8/13/2007 5:40:03 AM

0

Since the actual name of the role ("Administrators", "General") is a string, you are on the right track, reducing the number of occurances for these string literals in the code. Always think about what will happen if you need to rename a role?

Your approach where you have methods hiding the actual "string name" of the role is definitely a way to go. Instead of having these methods in each page, you can place them in a static utility class in App_Code. Or in your Master page (if you're using it). That way, you need only to define this methods (should really be properties) once.

Another option you have to get past this string literal dependency, is to go for enums.If you to create a RoleManager class in App_Code. This RoleManager exposes a Role enum, and this Role enum can be used in the static method IsInRole. So your code would be:

panel1.Visible = RoleManager.IsInRole(Role.Administrator)

Good luck!

If this post was useful to you, please mark it as answer. Thank you!
CRONER
Asp.Net User
Re: Adding Roles that can update caledar, news, photos etc...8/14/2007 5:14:35 AM

0

I found a quick and dirty fix, considering that only one bool is registered and is called Admin, but that utilizes more than one role group.

this seems to be working when tested locally

protected void Page_Load(object sender, EventArgs e)

{

bool isAdmin = User.IsInRole("Administrators") || User.IsInRole("Kings");

panel1.Visible = isAdmin;

panel2.Visible = isAdmin;

}

}

All i added is another role to the same bool so i have less code to edit later on... this is done by || inclusion,

If you modify other "list" pages same way this worked for me, for example, in news_list page i just added the same line and it worked,

protected bool IsAdmin;

 

protected void Page_Load(object sender, EventArgs e)

{

IsAdmin = User.IsInRole(
"Administrators") || User.IsInRole("Kings");

panel1.Visible = IsAdmin;

}

What johram suggested is a file in app_code is probbably a what a good programer would do, but for us low tec trying to be programes that creates headackes in itself, so this is a lowtec solution, especially if this is done in the code behind page of your aspx pages, since they get precompiled and put in the bin foler, just like the app_code files do.

Thank you again all!


CRONER
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Adding Roles that can update caledar, news, photos etc... - ASP ... Adding Roles that can update caledar, news, photos etc... Last post 08-14-2007 1 :14 AM by CRONER. 2 replies. Sort Posts: ...
Textbox in Updatepanel - asp.net_ajax.asp.net_ajax_ui - fix error ... adding roles that can update caledar, news, photos etc... password retrieval message body · how the club web site margins shrink as you change browser size ...
Website Hosting for Bands - BandSite Software Manual Adding images and photos to your website is such a broad topic that it deserves its own section. ..... Every week, update your upcoming news, events, etc. ...
Novalsys - Innovative Systems for Educational Services Group news can be published on the school-wide newsletter ... List of published photos and files; Group contact information; Group calendar and event ...
This Just in! Nile Network News Update The teacher can also be creative about playing the role of the editor or ... civics, earth sciences (irrigation), astronomy (astrolabe and calendar). ...
ENHANCING STUDENT MOBILITY BY A WEB 2.0 PLATFORM. THE ERASMUS ... members can update in an extremely intuitive way. ... (news with comments, events calendar, partners list, customizable photo gallery, private ...
Website Design Company, Web Development SA Bezaleel can add news items, update the information about the children and make changes to the ... photo gallery; calendar; articles; newsletters; comments ...
Broncos Cheerleaders swimsuit calendar shoot : Broncos : The Rocky ... Jul 8, 2008 ... SLIDE SHOW:Broncos Cheerleaders calendar photos · SLIDE SHOW: Broncos Cheerleaders .... took on the role of stylist for the 2009 Calendar. ...
DaCdb - Help for Club Secretaries 8) Submitting a Club event or Fund Raiser event to the Club Calendar .... Update CLUB roles for Presidents, Pres-elect, Secretary, Sec-elect, etc. ...
Inside Groupee / Blog Thus, you can update periodically to keep your Record Collection up to date. ... you had to choose a “post type”- a story, video, photo album, etc. ...

Videos:
Long Beach City Council Meeting Long Beach City Council Meeting






select treeviewnode

menu z-index problem???

when would you like to relase a new version?

css adapter and ajax

menu adapter - selected item image problem

problems with css adapters and formview / gridview

updated version of treeview css adapter - improved postback and state handling

detailsview rendered as overlaped name and value

setting css class for tbody of gridview

detailsview controlstyle properties lost

treeviewadapter and showexpandcollapse?

two menus on the page- with css adapters and without

css friendly control adapters: menu incremental expansion of items on demand (when they are clicked)

staticdisplaylevels on menu no effect?

expanded menu problem in ie 7 only

treeview menu - collapsing when click on a new page... how do i keep it expanded to the selected node?

css treeview and a master page (never meant to be?)

hover causes list item to expand when not a leaf node

rendered id attributes

css adaptors

is it possible to apply css adapters to a single specific control?

is there any good tutorial available?

stylesheet question

status bar - onmouseover

problem centering menu control using adpaters

menuadapter / builditem method

wishes + two classes

fix: ie7 ghost menu problem

gridview with a linked formview; cancel command requires two clicks

css friendly menu problems on ie 6.0

   
  Privacy | Contact Us
All Times Are GMT