Control the render of SharePoint Page


If you want to control the render of SharePoint Page like disable the controls, add new control, hide ribbon menu, ECB Menu….you can user the delegate control to do it:

<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<script language="c#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
    SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
    if (ribbon != null)
    {
        bool isDisableOpenWithExplorer = true;
        SPUser currentUser = SPContext.Current.Web.CurrentUser;

        SPGroupCollection groups =     currentUser.Groups;
        foreach (SPGroup groupItem in groups)
        {
            if(groupItem.Name.Equals("Display Explorer View",StringComparison.InvariantCulture))
            {
                isDisableOpenWithExplorer = false;
                break;
            }
        }
       
        if(isDisableOpenWithExplorer)
        {
            ribbon.TrimById("Ribbon.Library.Actions.OpenWithExplorer");
        }

    }
}
</script>

Comments

Popular posts from this blog

Referencing Javascript Files with SharePoint 2010 Custom Actions using SciptSrc

Configure Excel Services data access by using external data connection

Uninstall SQL Server Embedded