다음을 통해 공유


ConsoleAction Class

Represents the base class which all specific console actions to be used in the ConsoleDataSource must inherit.

Inheritance Hierarchy

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
      Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ConsoleAction
        

Namespace:  Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Syntax

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public MustInherit Class ConsoleAction _
    Inherits WebControl _
    Implements IPostBackEventHandler
'Usage
Dim instance As ConsoleAction
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public abstract class ConsoleAction : WebControl, 
    IPostBackEventHandler

Remarks

The Editing Menu, Quick Access Menu, or Site Actions menu present various actions to the user. Each of these menus contains an instance of the ConsoleDataSource object that provides a hierarchical collection of ConsoleNode objects, some of which implement the ConsoleAction class. Each implementation of this class represents a specific action, such as Create Page, Publish, Show Version History, or Save and Stop Editing.

The code example presented here is simplified, but shows how a console action should be constructed. Running this sample application adds a "Save and Stop Editing" button to the Quick Access Menu. It requires that the page be in Edit mode and that the user have EditListItem permissions to this PublishingPage object. The sample uses ECMAScript (JavaScript, JScript) to post back to this control, and when it raises a postback event, the event saves the current PublishingPage object and shows the saved page in display mode.

Examples

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions;

/// Assemblies that need to be referenced in this sample;
///     Microsoft.SharePoint.dll
///     Microsoft.SharePoint.Publishing.dll
///     Microsoft.Web.CommandUI.dll
namespace Microsoft.SDK.SharePointServer.Samples.Publishing.RteExtensions
{
    public class RteExtensionsAction : ConsoleAction
    {
        /// <summary>
        /// This Console Action will include on the client a reference to RteExtension.js file 
        /// on pages that have a Rich Text Editor.
        /// </summary>
        public RteExtensionsAction()
            : base()
        {
        }

        /// <summary>
        /// Gets the rights required for this console action to be active on the page.
        /// 
        /// For this example, we will have the same value as the Publishing Rich Text Editor
        /// which requires Edit List Item Right, since we want to activate under
        /// the same circumstances.
        /// </summary>
        /// <value>
        /// The rights required for this console action to be active on the page.
        /// </value>
        public override SPBasePermissions UserRights
        {
            get { return SPBasePermissions.EditListItems; }
        }

        /// <summary>
        /// The value returned by this function represents a list of Ribbon tabs, if these
        /// ribbon tabs are currently shown, then this console action will be activate on this page.
        /// 
        /// For this example, we are specifying the Format Text tab, which is requested
        /// when the Publishing Rich Text Editor is on the page. Also, we are adding a new
        /// button to this tab, and hence we want to activate when that button is present on
        /// the page.
        /// </summary>
        /// <returns>
        /// A list of ribbon tabs for which the ConsoleAction is activated.
        /// </returns>
        public override string[] GetRibbonTabIdsWhereConsoleActionIsShown()
        {
            return new string[] { SPRibbon.EditTabId };
        }

        /// <summary>
        /// If the UserRights are met and the Ribbon Tabs have been found, then this method will be called.
        /// This is where you register your appropriate ribbon files and send to the client data it requires.
        /// 
        /// For this example, we will tell SharePoint ScriptLink about the existance of RteExtensions.js.
        /// This will allow code on the client to download it on demand. 
        /// The second part will register a startup script that will download RteExtensions.js once the
        /// SharePoint rich text editor file (sp.ui.rte.js) has finished downloaded.
        /// </summary>
        public override void RegisterClientData()
        {
            // Register the extension script, such that it can be downloaded on demand.
            ScriptLink.RegisterOnDemand(this.Page, "RteExtensions.js", false);

            // Download the RteExtension script when the SharePoint RTE has finished downloaded.
            string onDemandScript = @"
// This method informs SharePoint to start downloading the Script On Demand
// file that was registered on the server.
function loadRteExtensions()
{
// Include the RteExtensions.js if it is not already on the page.
var defd;
try
{
defd = typeof(RteExtensions);
}
catch (e)
{
defd = 'undefined';
}
EnsureScript('RteExtensions.js', defd, null);
}
// This method is run when the body has finished loading.
// Inform SharePoint to wait until the rich text editor has been 
// downloaded on the page before including the rte extensions.
function loadExtensionsDependencies()
{
ExecuteOrDelayUntilScriptLoaded(loadRteExtensions, 'sp.ui.rte.js');
}
// Add to the SharePoint array of functions to call when the 
// body of the document has finished loading
// Wait for the page to have completed to load
// this will make sure that all script on demand information
// has been processed by SharePoint.
if (_spBodyOnLoadFunctionNames != null)
{
_spBodyOnLoadFunctionNames.push('loadExtensionsDependencies');
}
";
            Page.ClientScript.RegisterStartupScript(typeof(RteExtensionsAction), "RteExtensionsAction", onDemandScript, true);
        }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ConsoleAction Members

Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions Namespace

ConsoleNode

ConsoleDataSource

IsCurrentlyEnabled

RaisePostBackEvent

RefreshCurrentItemAfterUpdate

ShowError

Inheritance Hierarchy

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
      Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ConsoleAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ApproveOrDeclineAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.BaseApproveAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.BaseDeclineAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.BrowseWebPartsAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CancelApprovalRequestAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CancelApprovalWorkflowRequestAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CancelSchedulingAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CheckInAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CheckInWithCommentAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CheckOutAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CheckOutOverrideAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CopyAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CreateNewPublishingPageAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CreateNewSiteAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CreateNewsLinkAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CreatePageVariationAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.CreateSiteVariationAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.DeleteAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.EditListItemPropertiesAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.EditPropertiesAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ExitMenuAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ExitWithoutSavingAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ForceSavePublishingPageAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ImportWebPartsAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ManageSiteAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ModifyNavigationAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ModifyPagesLibrarySettingsAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.MoveAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.OneClickPublishAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.PageLayoutAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.PersonalViewAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.PreviewAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.PreviewExistingPublishingPageAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.PublishAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.PublishWithCommentAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.QuickDeployAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ReviewPublishingPageAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.RevisionHistoryAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.RTEV4Action
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SavePublishingPageAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SchedulingAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SearchWebPartsAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SharedViewAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ShowUnapprovedResourcesAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SiteDirectoryBrokenLinksCheckerAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SiteSettingsAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SpellCheckEntirePageAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SwitchToAuthoringModeAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.SwitchToPublishedModeAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.UndoCheckOutAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.UnpublishAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.UpdateVariationsAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.VersionDifferenceAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.VersionInfoAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ViewAllSiteContentAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ViewChangesPageVariationAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.ViewRecycleBinAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.WorkflowStartAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.WorkflowStatusAction
        Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.WorkflowTasksAction
        Microsoft.SharePoint.Publishing.WebControls.SpellCheckV4Action