locked
Admin link in Master RRS feed

  • Question

  • User-2058016573 posted

    I've got the MaineOne admin tool integrated with the Club site.  I would like to have a clickable image display in the footer of all pages that will take the user to the WebAdmin.aspx page IF they are an administrator.  I'm attempting to add it to the footer section of the Default.master, but it doesn't seem to be recognizing the User property like the other pages do.  Other pages that reference the IsAdmin work fine, so I'm wondering if there is something different with the master page.

    Here's the code I inserted for the master page.

     In the <script> tag, I added three lines for the Page_Load (bolded):

    Private IsAdmin As Boolean
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    If Page.User.Identity.IsAuthenticated Then
    Membership.GetUser(Membership.GetUser.ProviderUserKey(), True)
    End If
    IsAdmin = User.IsInRole("Administrators")
    Admin.Visible = IsAdmin

    End Sub

    And then in the footer section, I added a panel tag:

    <p>
    <asp:Panel runat="Server" ID="Admin" Visible='<%#IsAdmin %>'>
    <asp:Hyperlink ID="AdminHyperlink" runat="server" BorderStyle="None" NavigateUrl="~/webadmin.aspx"><img alt="Restricted Area" src="images/sm_RestrictedArea.jpg" />
    </asp:Hyperlink>
    </asp:Panel>
    </p>

    Any idea how to get this to work?

    Thanks,
    Kevin

    Thursday, July 26, 2007 12:32 PM

All replies

  • User2069888697 posted

     Change to this.

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            
            If Page.User.IsInRole("Administrators") Then
                Admin.Visible = True
            End If

        End Sub

     

    <p>
    <asp:Panel runat="Server" ID="Admin" Visible=False
    <asp:Hyperlink ID="AdminHyperlink" runat="server" BorderStyle="None" NavigateUrl="~/webadmin.aspx"><img alt="Restricted Area" src="images/sm_RestrictedArea.jpg" />
    </asp:Hyperlink>
    </asp:Panel>
    </p>

     

     

    Thursday, September 20, 2007 4:54 PM
  • User-2058016573 posted

    Thanks boss, I got it sorted out.  I love your admin tools for this starter kit!

    Kevin

    Wednesday, September 26, 2007 12:39 PM