Answered by:
ClubStarter Kit - Making a lable appear on certain members in MembershipList.aspx

Question
-
User75903138 posted
I am trying to create a new label that will only show up if the user is in the right group
As you can see the "BMW MOFO Member" label shows up on all members. I've have already create a membership role call "bmwmofoMember". Right now what it looks like it's doing is it's checking the current user login and if the user is in the "bmwmofoMember" role than it will display the label on the member list.
Here's the code I have so far:
Public
Function isMember() As Boolean If User.Identity.IsAuthenticated Then Return Visible = True Else Return Visible = False End If End Function<
ItemTemplate> <div class="membercard"> <p> <asp:Label ID="bmwmofoMember" Visible='<%# isMember() %>' runat="server" BackColor="LightGreen" Font-Bold="true" Text="BMW MOFO Member" /> </p>How would I do this?
Tuesday, March 11, 2008 4:08 PM
Answers
-
User2069888697 posted
Sorry read it wrong.
Try this. I have not verified it, but it should get you in the right direction.
change call to function to
Visible
='<%# isMember(Cstr( Eval("Email"))) %>'Change function to
Public Function isMember(ByVal email As String) As Boolean- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 11, 2008 7:42 PM
All replies
-
User2069888697 posted
What yo have now only checks to see if the user is authenticated any role will show it. To check which role they are in you need to use
If user.IsInRole("BMW MOFO MEMBER") then
Tuesday, March 11, 2008 4:58 PM -
User75903138 posted
I tried that and samething. I think what I need to do is pass the UserName through and then it should check to see if the user is in the "bmwmofoMember" group. But I don't know how to write the function to do that. Any other suggestions?
Tuesday, March 11, 2008 5:42 PM -
User2069888697 posted
Sorry read it wrong.
Try this. I have not verified it, but it should get you in the right direction.
change call to function to
Visible
='<%# isMember(Cstr( Eval("Email"))) %>'Change function to
Public Function isMember(ByVal email As String) As Boolean- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 11, 2008 7:42 PM -
User2069888697 posted
If that works the only flaw I do know will happen is if your membership is not set up as requiresUniqueEmail="true" then it you could end up with a false showing if there are 2 members with the same email but not the same roles.
Tuesday, March 11, 2008 7:51 PM -
User75903138 posted
It worked! I'm not to worry about the email part. It won't let you sign up for membership if the input of their email address already exist. Thanks for everything!
Tuesday, March 11, 2008 8:49 PM