Ribbon customization : how to hide Ribbon programatically
programatically hide a Ribbon
public
void
HideRibbon()
{
SPRibbon current = SPRibbon.GetCurrent(
this
.Page);
if
(current !=
null
&& !
this
.Page.Request.IsAuthenticated)
{
current.CommandUIVisible =
false
;
}
}
programatically hide a single ribbon button
public
void
HideRibbonItem()
{
//if this is a System.Web.UI.Page
SPRibbon ribbon = SPRibbon.GetCurrent(
this
);
ribbon.TrimById(
"Ribbon.ListItem.New.NewFolder"
);
}
programatically hide the status bar
public
void
HideStatusBar()
{
string
script =
"document.onreadystatechange=fnRemoveAllStatus; function fnRemoveAllStatus(){removeAllStatus(true)};"
;
this
.Page.ClientScript.RegisterClientScriptBlock(
typeof
(HideTheRibbon),
"statusBarRemover"
, script,
true
);
}
programatically hide the SiteActions Menu
public
void
HideSiteActionsMenu()
{
SiteActions actions = SiteActions.GetCurrent(
this
.Page);
if
(actions !=
null
&& !
this
.Page.Request.IsAuthenticated)
{
actions.Visible =
false
;
}
}
No comments:
Post a Comment