Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking 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 Basics 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 January 24th, 2007, 09:55 AM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default RoleGroups and Roles

The following code behaves like a case statement. As soon as a matching role is found it exits. I have users that have multiple roles and I need to return all of their roles.

    <asp:LoginView ID="LoginView1" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="Reporter">
                <ContentTemplate>
                    As a reporter you can update scores and match reports.
                </ContentTemplate>
            </asp:RoleGroup>
            <asp:RoleGroup Roles="Administrator">
                <ContentTemplate>
                    As an administrator you have full access to all admin pages.
                </ContentTemplate>
            </asp:RoleGroup>
            <asp:RoleGroup Roles="Owner">
                <ContentTemplate>
                    Hi Jim. As the owner you can change the news, the squad
                    and the match fixtures.
                </ContentTemplate>
            </asp:RoleGroup>
            <asp:RoleGroup Roles="Manager">
                <ContentTemplate>
                    As the manager you can edit the news and schedule matches.
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>

thanks dan
 
Old May 11th, 2007, 08:54 AM
Authorized User
 
Join Date: Jul 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Tremmorkeep Send a message via MSN to Tremmorkeep Send a message via Yahoo to Tremmorkeep
Default

I dont know if you already got your answer. I'm sorry I havent been on the forums for a while. The answer is yes, there is a default. It is the <loggedintemplate> which, if no roles are found in the Rolegroups then this template will be the one shown. Best of luck!


 
Old September 19th, 2007, 10:55 AM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am having the same issue the roles are treating the content template as a case statement and I also need to return all roles associated to the user. Please help..

 
Old September 19th, 2007, 01:24 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

This is a known limitation of the LoginView. Take a look at the docs: http://quickstarts.asp.net/QuickStar...loginview.aspx
Quote:
quote:There is no attempt by the control to merge all of the templates that the user is eligible to see based on all of their role group associations or to select the most privileged role group template. For example if a user is in both the customer and admin role groups and the customer template is sequentially before the admin template, that user will only ever see the customer template.
You can replicate the behavior quite easily with a few placeholders and some code behind:
Code:
<asp:Placeholder id="plcAdmin" runat="server/>
 As an administrator you have full access to all admin pages.
</asp:Placeholder>
<asp:Placeholder id="plcOwner" runat="server/>
  Hi Jim. As the owner you can change the news, the squad
  and the match fixtures.
</asp:Placeholder>
Combined with this code in the code behind:
plcAdmin.Visible = User.IsInRole("Administrator")
plcOwner.Visible = User.IsInRole("Owner")

Not ideal, but it may work for you....

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004





Similar Threads
Thread Thread Starter Forum Replies Last Post
Roles bhasker_braj121 SQL Server 2005 1 January 19th, 2008 12:10 PM
Chapter 6 Roles hdpark BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 November 16th, 2007 07:43 PM
roles and management MunishBhatia ASP.NET 2.0 Professional 2 November 3rd, 2007 01:01 AM
RoleGroups common templates Tremmorkeep ASP.NET 2.0 Basics 1 May 11th, 2007 09:30 AM
Roles jackandjo BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 October 17th, 2006 03:12 AM





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