Jump to content
kwilliams

Asp:rolegroup: Only Pulls First Rolegroup In List

Recommended Posts

I have a very simple page that displays a link for each rolegroup that a member belongs to with ASP.NET membership, lets say Group1 and Group2. For some reason, I can only see the first of two links in a list, regardless of which group it is.I've already verified that both groups are pulling in fine by moving the Group2 link above Group1 to see if it could be viewed: which it was!If Group1 is listed above Group 2, I see the link to Group1. But if I move the link for Group2 above Group1, I see the Group 2 link. I don't have a bunch of snazzy-dazzy complicated code on this page, so I'm stumped. Why could this be happening? I'd appreciate any help. Here is my code:groups.aspx.vb

Partial Class groups	Inherits System.Web.UI.Page	'Pull username	Dim strLoginUserID As String = Context.User.Identity.NameEnd Class

groups.aspx

<%@ Page Language="VB" title="List of Groups" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" EnableSessionState="true" EnableViewState="false" CodeFile="groups.aspx.vb" Inherits="groups" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">	<asp:LoginView ID="LoginView1" runat="server">		<RoleGroups>			<asp:RoleGroup Roles="Group1">				<ContentTemplate>					You are a member of group 1: <asp:HyperLink ID="hlGroup1" NavigateUrl="group1.aspx" runat="server">Group1</asp:HyperLink>				</ContentTemplate>			</asp:RoleGroup>			<asp:RoleGroup Roles="Group2">				<ContentTemplate>					You are a member of group 2: <asp:HyperLink ID="hlGroup2" NavigateUrl="group2.aspx" runat="server">Group2</asp:HyperLink>				</ContentTemplate>			</asp:RoleGroup>		</RoleGroups>	</asp:LoginView></asp:Content>

Share this post


Link to post
Share on other sites

I received this response from somewhere else:The LoginView only displays content for the *first* matched RoleGroup, not for all matching groups:http://msdn.microsoft.com/en-us/library/sy...rolegroups.aspxWhat a bummer, huh? So I'm now thinking of dynamically handling the links on the code-behind (show/hide) depending on their roles using the User.IsInRole method, kinda like this:If User.IsInRole("Group1") Then hlGroup1.Visible = TrueElseIf If User.IsInRole("Group2") Then hlGroup2.Visible = TrueEnd IfThanks anyway!

Share this post


Link to post
Share on other sites
If User.IsInRole("Group1") Then hlGroup1.Visible = TrueElseIf If User.IsInRole("Group2") Then hlGroup2.Visible = TrueEnd If
I'm pretty sure that would generate an error.

Share this post


Link to post
Share on other sites

He means the extra if.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...