views:

360

answers:

2

I am trying to hide the site actions menu from certain pages with our moss enviroment, specifically non-publishing pages.

I was looking to use the SPSecurityTrimmedControl to achieve it, so in my masterpage I have:

<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ApproveItems">
<PublishingSiteAction:SiteActionMenu runat="server"/>
</SharePoint:SPSecurityTrimmedControl>

but it seems that this is role based only and not page based. Can anyone suggest an alternative?

A: 

I am not sure if this is the best way to do this or not... but I've had to something similar (hiding/displaying stuff). I created a UserControl and then included it in the masterpage.

1. Write the code behind your user control

namespace YourCompany.Namespace
{
    public class HideSiteActionsClass : System.Web.UI.UserControl
    {
        protected override void  OnLoad(EventArgs e)
        {
            // do work to hide site actions depending on page
        }
    }
}

2. Create your usercontrol ascx file

Contents of C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\YourUserControl.ascx

<%@ Control Language="C#" Inherits="YourCompany.Namespace.HideSiteActionsClass,YourDLLThatHasTheClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b4145551be317a94" compilationMode="Always" %>

3. Add your usercontrol to the masterpage

Put this at the top:

<%@ Register TagPrefix="yourTagPrefix" TagName="YourTagName" src="~/_controltemplates/YourUserControl.ascx" %>

Put this somewhere on the page:

<yourTagPrefix:YourTagName id="AUserControlID" runat="server" EnableViewState="false"></yourTagPrefix:YourTagName>

You can find info on google or this page.

Kit Menke
+1  A: 

A pretty way is to build your own wrapper control that hides its child controls based on some criteria that you specify. Exactly like the SPSecurityTrimmedControl!

See Waldeks blog entry. He is hiding the Action menu for anonymous users so you would only have to put in your own criterium.

ArjanP