protected static void AddContextualTab(Page page, string initialTabId, string approvalsTab) { var ribbon = SPRibbon.GetCurrent(page); if (ribbon != null) { ribbon.Minimized = false; ribbon.CommandUIVisible = true; if (!ribbon.IsTabAvailable(initialTabId)) { ribbon.MakeTabAvailable(initialTabId); } } var language = SPContext.Current.Web.Language.ToString(); Microsoft.Web.CommandUI.Ribbon ribbon1 = SPRibbon.GetCurrent(page); var ribbonExtensions = new XmlDocument(); ribbonExtensions.LoadXml(approvalsTab.Replace(LanguageId, language)); ribbon1.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListContextualGroup._children"); ribbonExtensions.LoadXml(Properties.Resources.flexible2); ribbon1.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Templates._children"); ribbonExtensions = new XmlDocument(); ribbonExtensions.LoadXml("<Button Id=\"Ribbon.List.Datasheet.Print\" Sequence=\"10\" Command=\"PrintGrid\" Image16by16=\"/_layouts/epmlive/images/print.gif\" Image32by32=\"/_layouts/epmlive/images/printmenu.gif\" LabelText=\"Print\" ToolTipTitle=\"Print\" ToolTipDescription=\"\" TemplateAlias=\"o1\"/>"); ribbon1.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.List.Share.Controls._children"); ribbonExtensions = new XmlDocument(); ribbonExtensions.LoadXml(Properties.Resources.txtTimesheetTemplate.Replace(LanguageId, language)); ribbon1.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Templates._children"); }
private void AddContextualTab() { var currentWeb = SPContext.Current.Web; var ribbon = SPRibbon.GetCurrent(Page); if (ribbon != null) { ribbon.Minimized = false; ribbon.CommandUIVisible = true; const string InitialTabId = "Ribbon.ListItem"; if (!ribbon.IsTabAvailable(InitialTabId)) { ribbon.MakeTabAvailable(InitialTabId); } } var language = currentWeb.Language.ToString(); Ribbon ribbon1 = SPRibbon.GetCurrent(Page); var ribbonExtensions = new XmlDocument(); ribbonExtensions.LoadXml(Resources.txtResourcePlannerTab.Replace("#language#", language)); ribbon1.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ListContextualGroup._children"); ribbonExtensions = new XmlDocument(); ribbonExtensions.LoadXml(Resources.gridribbontemplate.Replace("#language#", language)); ribbon1.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Templates._children"); }
protected override void CreateChildControls() { //SPSecurity.RunWithElevatedPrivileges(delegate() //{ SPRibbon current = SPRibbon.GetCurrent(this.Page); if (current != null) { current.MakeTabAvailable("Ribbon.Read"); current.InitialTabId = "Ribbon.Read"; current.Minimized = true; } //}); //current.TrimById("Ribbon.ListForm.Display"); //SPRibbonScriptManager manager = new SPRibbonScriptManager(); //List<IRibbonCommand> commands = new List<IRibbonCommand>(); //bool admin = base.GlobalAdmin.IsCurrentUserMachineAdmin(); //commands.Add(new SPRibbonCommand("WebAppTab")); // <script type='txt/javascript'> //_spBodyOnLoadFunctionNames.push("InitTab"); //function InitTab() //{ //InitializeTab("Ribbon.Document"); //} //</script> }
/// <summary> /// Adding ribbon tab to control's page here /// </summary> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (!DisplayTab) { return; } var tabDefinition = GetTabDefinition(); try { if (SPRibbon.GetCurrent(this.Page) == null) { return; } if (tabDefinition != null && !this.DesignMode) { RibbonController.Current.AddRibbonTabToPage(tabDefinition, this.Page, false); } } catch (Exception ex) { SPDiagnosticsService diagSvc = SPDiagnosticsService.Local; diagSvc.WriteTrace(0, new SPDiagnosticsCategory("Fluent Ribbon", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, "Error occured: " + ex.Message + "\nStackTrace: " + ex.StackTrace); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); //buildParams(); getGanttParams(); var webPartPageComponentId = SPRibbon.GetWebPartPageComponentId(this); if (!Page.ClientScript.IsClientScriptBlockRegistered(GetType(), $"listviewwebpart{webPartPageComponentId}")) { Page.ClientScript.RegisterClientScriptBlock( GetType(), $"listviewwebpart{webPartPageComponentId}", $"<script language=\"javascript\">var mygrid{sFullGridId};var G2antt1{ZoneIndex}{ZoneID};</script>"); } if (SPContext.Current.ViewContext.View != null) { AddContextualTab(); var clientScript = Page.ClientScript; clientScript.RegisterClientScriptBlock(GetType(), "ContextualWebPart", DelayScript); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (SPContext.Current != null) { GetSources(); } var tabDefinition = GetTabDefinition(); try { if (SPRibbon.GetCurrent(this.Page) == null) { return; } if (tabDefinition != null && !this.DesignMode) { RibbonController.Current.AddRibbonTabToPage(tabDefinition, this.Page, false); } } catch (Exception ex) { ex.ToString(); } }
// Private Methods (1) /// <summary> /// Adds the contextual tab. /// </summary> private void AddContextualTab() { SPRibbon spRibbon = SPRibbon.GetCurrent(Page); if (spRibbon == null) { return; } var ribbonExtensions = new XmlDocument(); ribbonExtensions.LoadXml(_contextualTab.Replace("{title}", DisplayTitle)); spRibbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ContextualTabs._children"); ribbonExtensions.LoadXml(_contextualTabTemplate); spRibbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Templates._children"); spRibbon.Minimized = false; spRibbon.CommandUIVisible = true; if (!spRibbon.IsTabAvailable(MANAGE_TAB)) { spRibbon.MakeTabAvailable(MANAGE_TAB); } }
private void CheckRibbonBehavior() { SPRibbon spRibbon = SPRibbon.GetCurrent(Page); if (spRibbon == null) { return; } //Ribbon Behaviour: SPList list = SPContext.Current.Web.Lists.TryGetList("Resources"); EPMLiveCore.GridGanttSettings gSettings = new EPMLiveCore.GridGanttSettings(list); string resourceRibbonBehavior = gSettings.RibbonBehavior; switch (resourceRibbonBehavior) { case "2": //Hidden { spRibbon.TrimById(HIDE_TAB); spRibbon.TrimById(PAGE_TAB); spRibbon.TrimById(MANAGE_TAB); spRibbon.TrimById(VIEWS_TAB); } break; } }
// Protected Methods (1) /// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { string webPartId = UniqueID.Md5(); WebPartManager currentWebPartManager = WebPartManager.GetCurrentWebPartManager(Page); if (currentWebPartManager != null && currentWebPartManager.DisplayMode != WebPartManager.DesignDisplayMode && currentWebPartManager.DisplayMode != WebPartManager.EditDisplayMode) { AddContextualTab(); CheckRibbonBehavior(); ClientScriptManager clientScriptManager = Page.ClientScript; string script = DelayScript .Replace("{webPartPageComponentId}", SPRibbon.GetWebPartPageComponentId(this)) .Replace("{gridId}", webPartId); clientScriptManager.RegisterClientScriptBlock(GetType(), "ResourceGridWebPart", script); } var control = (ResourceGridUserControl)Page.LoadControl(ASCX_PATH); control.WebPartId = webPartId; control.AutoFocus = WebPartManager.WebParts.Count == 1; control.WebPartQualifier = Qualifier; control.WebPartHeight = Height; Controls.Add(control); }
/// <summary> /// Section Constructor /// </summary> /// <param name="ribbon">the Ribbon that this Section was created by and is a part of</param> /// <param name="id">Component id of the Secton</param> /// <param name="type">type of the section</param> internal Section(SPRibbon ribbon, string id, SectionType type, SectionAlignment alignment) : base(ribbon, id, "", "") { _type = type; _alignment = alignment; switch (type) { case SectionType.ThreeRow: AddChildInternal(new Row(ribbon, id + "-0"), false); AddChildInternal(new Row(ribbon, id + "-1"), false); AddChildInternal(new Row(ribbon, id + "-2"), false); break; case SectionType.TwoRow: AddChildInternal(new Row(ribbon, id + "-0"), false); AddChildInternal(new Row(ribbon, id + "-1"), false); break; case SectionType.OneRow: AddChildInternal(new Row(ribbon, id + "-0"), false); break; case SectionType.Divider: break; default: throw new ArgumentException("Invalid SectionType"); } }
public override Group CreateGroup(SPRibbon ribbon, string id, GroupProperties properties, string title, string description, string command, Dictionary <string, List <Control> > controls, Dictionary <string, string> pars) { DeclarativeTemplateBuildContext bc = new DeclarativeTemplateBuildContext(); bc.Ribbon = ribbon; bc.Controls = controls; bc.Parameters = pars; Group group = ribbon.CreateGroup(id, properties, title, description, command); // Loop through the Layouts for this group and create them. JSObject[] children = DataNodeWrapper.GetNodeChildren(_data); for (int i = 0; i < children.Length; i++) { Layout layout = CreateLayoutFromData(children[i], group, bc); if (!CUIUtility.IsNullOrUndefined(layout)) { group.AddChild(layout); } } return(group); }
/// <summary> /// Builds and adds the custom ribbon tab /// </summary> protected virtual void AddRibbonTab() { try { // Gets the current instance of the ribbon on the page and replaces it with the custom ribbon. Ribbon = SPRibbon.GetCurrent(this.Page); XmlDocument ribbonExtensions = new XmlDocument(); Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("{0}.{1}.xml", RIBBON_XML_FILE_LOCATION, "SPAtab")); XmlTextReader mainTab = new XmlTextReader(stream); ribbonExtensions.Load(mainTab); Ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Tabs._children"); // Adds the custom tab stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("{0}.{1}.xml", RIBBON_XML_FILE_LOCATION, "SPAcontextualtab")); XmlTextReader contextualTab = new XmlTextReader(stream); ribbonExtensions.Load(contextualTab); Ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Templates._children"); Ribbon.CommandUIVisible = true; if (!Ribbon.IsTabAvailable(RIBBON_INITIAL_TAB_ID)) { Ribbon.MakeTabAvailable(RIBBON_INITIAL_TAB_ID); } } catch (Exception ex) { SPA.Error.WriteError(ex); } }
public string GetCallbackResult() { try { if (result != null) { throw (result); } } catch (SPException exception) { base.SetGenericErrorMessage(exception); } base.RefreshPageState(); base.parentStateControl.OnPageStateChanged(); SPRibbon ribbon = SPRibbon.GetCurrent(this.Page); if (ribbon != null) { string currentTab = ribbon.ActiveTabId; ribbon.SetInitialTabId(currentTab, "WSSPageStateVisibilityContext"); } //UriBuilder builder = new UriBuilder(HttpContext.Current.Request.Url.OriginalString); //SPUtility.Redirect(builder.Uri.PathAndQuery, SPRedirectFlags.Trusted, HttpContext.Current); return(base.BuildReturnValue(string.Format("{0} has been changed.Refresh your page.", action))); }
/// <summary> /// Add ribbon tab to the specified page /// </summary> /// <param name="definition">Definition of the ribbon tab</param> /// <param name="page">Page, to which the definition will be added</param> /// <param name="makeInitial">if true, the ribbon tab will be active when page is loaded, otherwise the default tab (Browse) will be active</param> /// <remarks> /// <para> /// This method is intended to provide ability to add local ribbon customizations. The customizations have to be specified each time /// when the page gets loaded. To add permanent customizations, use <see cref="RibbonCustomAction"/>. /// </para> /// <para> /// This method cannot create contextual tabs, only static. /// </para> /// </remarks> /// <example> /// <para> /// Example of usage: /// </para> /// <code lang="csharp"> /// public class MyPage : LayoutsPageBase /// { /// public void Page_Load(object sender, EventArgs e) /// { /// RibbonController.Current.AddRibbonTabToPage(MyRibbonManager.MyTabDefinition, this, true); /// } /// } /// </code> /// <para> /// This will add initially active ribbon tab to the application page MyPage. /// Tab definition is supposed to be stored in some custom user class MyRibbonManager. /// </para> /// <para> /// Also its possible to use this method for adding tabs to ribbon from webparts. But you must provide different ribbon ids /// for different webparts and even for different instances of the same webpart. /// </para> /// </example> public void AddRibbonTabToPage(TabDefinition definition, Page page, bool makeInitial) { if (SPRibbon.GetCurrent(page) == null) { throw new Exception("SPRibbon.GetCurrent returned null for the specified page!"); } AddRibbonExtension(XmlGenerator.Current.GetTabXML(definition), page, "Ribbon.Tabs", makeInitial); AddGroupTemplatesRibbonExtensions(definition.GroupTemplates, page); var commands = new RibbonCommandRepository(); commands.AddCommands(definition); page.Items[CommandsKey] = commands; page.PreRenderComplete -= new EventHandler(page_PreRenderComplete); page.PreRenderComplete += new EventHandler(page_PreRenderComplete); Ribbon ribbon = SPRibbon.GetCurrent(page); ribbon.MakeTabAvailable("Ribbon." + definition.Id); if (makeInitial) { ribbon.InitialTabId = "Ribbon." + definition.Id; } }
/// <summary> /// Tab constructor /// </summary> /// <param name="ribbon">the Ribbon that created this Tab and that it is a part of</param> /// <param name="id">Component id of the Tab</param> /// <param name="title">Title of the Tab</param> /// <param name="description">Description of the Tab</param> /// <param name="contextual">whether this Tab is a contextual Tab or not</param> /// <param name="command">the command for this Tab. Used in enabling or disabling the tab.</param> /// <param name="contextualGroupId">the id of the ContextualGroup that this Tab is a part of.</param> internal Tab(SPRibbon ribbon, string id, string title, string description, string command, bool contextual, string contextualGroupId, string cssClass) : base(ribbon, id, title, description) { _lastScalingIndex = -1; _scalingInfo = new Scaling(); _contextual = contextual; _contextualGroupId = CUIUtility.SafeString(contextualGroupId); _command = CUIUtility.SafeString(command); _cssClass = CUIUtility.SafeString(cssClass); // Contextual tabs are invisible by default if (contextual) { VisibleInternal = false; } #if DEBUG if (command == "DEBUG_ALWAYS_ENABLED") { VisibleInternal = true; } #endif }
/// <summary> /// Creates a Group with this kind of template. /// </summary> /// <param name="ribbon">The Ribbon that this Group will be a part of.</param> /// <param name="id">Component id of the created Group</param> /// <param name="title">Title of the created Group</param> /// <param name="description">description of the created Group</param> /// <param name="command">command of the created Group(used for enabling/disabling through polling)</param> /// <param name="controls">array of Controls that will be used in the Temaplate(the order matters)</param> /// <param name="parameters">additional parameters for this Template</param> /// <returns>the created Group</returns> public abstract Group CreateGroup(SPRibbon ribbon, string id, GroupProperties properties, string title, string description, string command, Dictionary <string, List <Control> > controls, Dictionary <string, string> parameters);
/// <summary> /// Register the XML extension for the ribbon /// </summary> /// <param name = "xmlExtension">Ribbon XML extension string</param> /// <param name = "location">Location of the ribbon definition to register</param> public void RegisterRibbonExtension(string xmlExtension, string location) { var ribbonExtension = new XmlDocument(); ribbonExtension.LoadXml(xmlExtension); // Register the ribbon extension SPRibbon.GetCurrent(Page).RegisterDataExtension(ribbonExtension.FirstChild, location); }
private void HideRibbon() { SPRibbon ribbon = SPRibbon.GetCurrent(this.Page); if (ribbon != null) { ribbon.Minimized = true; } }
private void AddContextualTab() { Ribbon ribbon = SPRibbon.GetCurrent(Page); var ribbonExtensions = new XmlDocument(); ribbonExtensions.LoadXml(_contextualTab); ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.ContextualTabs._children"); ribbonExtensions.LoadXml(_contextualTabTemplate); ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Templates._children"); }
private void AddRibbonExtension(string xml, Page page, string parentId, bool makeInitial) { Ribbon ribbon = SPRibbon.GetCurrent(page); ribbon.CommandUIVisible = true; ribbon.Minimized = makeInitial ? false : ribbon.Minimized; XmlDocument ribbonExtensions = new XmlDocument(); ribbonExtensions.LoadXml(xml); ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, parentId + "._children"); }
/// <summary> /// Creates a new Group. /// </summary> /// <param name="ribbon">The Ribbon that this Group is created by and is a part of.</param> /// <param name="id">The unique Component id of this Group.</param> /// <param name="title">The Title of this Group.</param> /// <param name="description">The Description of this Group.</param> internal Group(SPRibbon ribbon, string id, string title, string description, string command, GroupProperties properties) : base(ribbon, id, title, description) { _command = command; _properties = properties; }
protected bool ValueIsDirty(DateTime lastUpdate) { #if !CUI_NORIBBON if (Root is SPRibbon) { SPRibbon rib = (SPRibbon)Root; return(lastUpdate < rib.LastScaleTime); } #endif return(false); }
private void AddGroupTemplatesRibbonExtensions(IEnumerable <GroupTemplateDefinition> templates, Page page) { Ribbon ribbon = SPRibbon.GetCurrent(page); XmlDocument ribbonExtensions = new XmlDocument(); foreach (GroupTemplateDefinition template in templates) { ribbonExtensions.LoadXml(template.XML); ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Templates._children"); } }
private void HideRibbonElements() { var rm = SPRibbon.GetCurrent(Page); if (rm != null && RibbonHiddenElements != null) { foreach (var element in RibbonHiddenElements) { rm.TrimById(element); } } }
private SPRibbon BuildRibbon(object data, RibbonBuildContext rbc) { JSObject ribbonElement = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.RIBBON); if (CUIUtility.IsNullOrUndefined(ribbonElement)) { throw new ArgumentNullException("No ribbon element was present in the data"); } Ribbon = new SPRibbon(DataNodeWrapper.GetAttribute(ribbonElement, "Id"), DataNodeWrapper.GetNodeAttributes(ribbonElement).To <RibbonProperties>()); //REVIEW(josefl) Should this be configurable? Ribbon.UseDataCookie = true; // Handle the Tabs // The XML structure that we are looking at is <Ribbon><Tabs><Tab/><Tab/>... JSObject[] tabChildren = DataNodeWrapper.GetNodeChildren( DataNodeWrapper.GetFirstChildNodeWithName(ribbonElement, DataNodeWrapper.TABS)); AddTabsToRibbon(tabChildren, "", rbc); // Handle the Contextual Tab Groups // The XML structure that we are looking at is <Ribbon><ContextualTabs><ContextualGroup>... object contextualTabs = DataNodeWrapper.GetFirstChildNodeWithName(ribbonElement, DataNodeWrapper.CONTEXTUALTABS); if (!CUIUtility.IsNullOrUndefined(contextualTabs)) { JSObject[] cgChildren = DataNodeWrapper.GetNodeChildren(contextualTabs); bool shownContextualGroupsSpecified = !CUIUtility.IsNullOrUndefined(RibbonBuildOptions.ShownContextualGroups); for (int j = 0; j < cgChildren.Length; j++) { if (shownContextualGroupsSpecified) { // Show the contextual group if it has been explicitly requested/ made available string cgId = DataNodeWrapper.GetAttribute(cgChildren[j], DataNodeWrapper.ID); if (!string.IsNullOrEmpty(cgId)) { if (!RibbonBuildOptions.ShownContextualGroups.ContainsKey(cgId) || CUIUtility.IsNullOrUndefined(RibbonBuildOptions.ShownContextualGroups[cgId])) { continue; } } } AddContextualGroup(cgChildren[j], rbc); } } return(Ribbon); }
public virtual void OnComponentCreated(Root root, string componentId) { // Set THE Ribbon for the page if it has not already been set. // REVIEW(josefl): Revisit this if we somehow allow more than one ribbon per page. if (typeof(SPRibbon).IsInstanceOfType(root) && CUIUtility.IsNullOrUndefined(Ribbon)) { Ribbon = (SPRibbon)root; } else { AddRoot(root); } }
// Private Methods (1) private void RegisterRibbon() { var xmlDocument = new XmlDocument(); SPRibbon spRibbon = SPRibbon.GetCurrent(Page); xmlDocument.LoadXml(Resources.MyWorkWebPart_ContextualTab.Replace("{title}", "My Work")); spRibbon.RegisterDataExtension(xmlDocument.FirstChild, "Ribbon.Tabs._children"); xmlDocument.LoadXml(Resources.MyWorkWebPart_ContextualTabTemplate); spRibbon.RegisterDataExtension(xmlDocument.FirstChild, "Ribbon.Templates._children"); spRibbon.Minimized = false; spRibbon.CommandUIVisible = true; }
protected override void CreateChildControls() { //SPSecurity.RunWithElevatedPrivileges(delegate() //{ SPRibbon current = SPRibbon.GetCurrent(this.Page); if (current != null) { current.MakeTabAvailable("Ribbon.Read"); current.InitialTabId = "Ribbon.Read"; current.Minimized = true; } //}); }
public bool CreateNew = false; // Create or Edit mode protected override void OnInit(EventArgs e) { InitHtmlEditors(); SPRibbon ribbon = SPRibbon.GetCurrent(this.Page); if (ribbon != null) { ribbon.CommandUIVisible = true; ribbon.TrimById("Ribbon.EditingTools.CPEditTab.Layout"); ribbon.TrimById("Ribbon.EditingTools.CPEditTab.Styles"); ribbon.TrimById("Ribbon.EditingTools.CPEditTab.EditAndCheckout"); } base.OnInit(e); }
protected override void OnPreRender(EventArgs e) { var list = SPContext.Current.List; var listName = list != null ? list.Title : string.Empty; string viewName; var viewContext = SPContext.Current.ViewContext; if (viewContext != null && viewContext.View != null) { viewName = viewContext.View.Title; } else { viewName = string.Empty; } ribbon = SPRibbon.GetCurrent(Page); ribbonCommands = new List <IRibbonCommand>(); RegisterRibbonExtension(SPContext.Current.Web, listName, viewName); if (isRegistedRibbons) { // Register required scripts ScriptLink.RegisterScriptAfterUI(Page, "CUI.js", false, true); ScriptLink.RegisterScriptAfterUI(Page, "SP.js", false, true); ScriptLink.RegisterScriptAfterUI(Page, "SP.Runtime.js", false, true); ScriptLink.RegisterScriptAfterUI(Page, "SP.Ribbon.js", false, true); // Register custom page component to handle custom ribbon commands if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "Register Ribbon Customization")) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Register Ribbon Customization", RibbonCustomizationScript, true); } // Register custom ribbon commands var ribbonScriptManager = new SPRibbonScriptManager(); ribbonScriptManager.RegisterGetCommandsFunction(Page, "getGlobalCommands", ribbonCommands); ribbonScriptManager.RegisterCommandEnabledFunction(Page, "commandEnabled", ribbonCommands); ribbonScriptManager.RegisterHandleCommandFunction(Page, "handleCommand", ribbonCommands); } base.OnPreRender(e); }
protected override void OnPreRender(EventArgs e) { var list = SPContext.Current.List; var listName = list != null ? list.Title : string.Empty; string viewName; var viewContext = SPContext.Current.ViewContext; if (viewContext != null && viewContext.View != null) { viewName = viewContext.View.Title; } else { viewName = string.Empty; } ribbon = SPRibbon.GetCurrent(Page); ribbonCommands = new List<IRibbonCommand>(); RegisterRibbonExtension(SPContext.Current.Web, listName, viewName); if (isRegistedRibbons) { // Register required scripts ScriptLink.RegisterScriptAfterUI(Page, "CUI.js", false, true); ScriptLink.RegisterScriptAfterUI(Page, "SP.js", false, true); ScriptLink.RegisterScriptAfterUI(Page, "SP.Runtime.js", false, true); ScriptLink.RegisterScriptAfterUI(Page, "SP.Ribbon.js", false, true); // Register custom page component to handle custom ribbon commands if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "Register Ribbon Customization")) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Register Ribbon Customization", RibbonCustomizationScript, true); } // Register custom ribbon commands var ribbonScriptManager = new SPRibbonScriptManager(); ribbonScriptManager.RegisterGetCommandsFunction(Page, "getGlobalCommands", ribbonCommands); ribbonScriptManager.RegisterCommandEnabledFunction(Page, "commandEnabled", ribbonCommands); ribbonScriptManager.RegisterHandleCommandFunction(Page, "handleCommand", ribbonCommands); } base.OnPreRender(e); }
public virtual void OnComponentCreated(Root root, string componentId) { // Set THE Ribbon for the page if it has not already been set. // REVIEW(josefl): Revisit this if we somehow allow more than one ribbon per page. if (typeof(SPRibbon).IsInstanceOfType(root) && CUIUtility.IsNullOrUndefined(Ribbon)) Ribbon = (SPRibbon)root; else AddRoot(root); }
private void RegisterWorkflowTriggerRibbon(SPRibbon ribbon) { ScriptLink.RegisterScriptAfterUI(this.Page, "CUI.js", false, true); ScriptLink.RegisterScriptAfterUI(this.Page, "SP.Ribbon.js", false, true); ScriptLink.RegisterScriptAfterUI(this.Page, "/_layouts/15/SharePoint.TestLab.WorkflowTrigger/js/WorkflowTriggerPageComponent.js", false, true); }
public RibbonComponent(SPRibbon ribbon, string id, string title, string description) : base(ribbon, id, title, description) { }