public void RegisterCustomCoreInScriptLink()
        {
            SPUserCustomAction objSPUserCustomActionScript = null;

            objSPUserCustomActionScript = this.CurrentWeb.UserCustomActions.Add();


            if (!CommonFunctions.IsExistsCustomAction("CustomCore.Js", "ScriptLink", String.Empty, this.CurrentWeb))
            {
                objSPUserCustomActionScript.Location  = "ScriptLink";
                objSPUserCustomActionScript.Name      = "CustomCore.Js";
                objSPUserCustomActionScript.ScriptSrc = "/_layouts/SampleProject/JS/CustomCore.js";
                this.CurrentWeb.AllowUnsafeUpdates    = true;
                objSPUserCustomActionScript.Update();
            }
        }
Esempio n. 2
0
        private void AddCustomAction(SPList spList)
        {
            string lableText         = "Multi download as ZIP";
            string urlToDownloadPage = SPContext.Current.Web.Url + "/_layouts/SPMultiZipDownload/SPMultiZipDownload.aspx?listId={SelectedListId}&itemId={SelectedItemId}";

            try
            {
                SPUserCustomAction customAction = spList.UserCustomActions.Add();
                customAction.Title              = Const.DownloadCustomActionTitle;
                customAction.Location           = "CommandUI.Ribbon";
                customAction.Group              = "SPMultiZipDownloadActionGroup";
                customAction.Rights             = SPBasePermissions.ViewListItems;
                customAction.CommandUIExtension =
                    "<CommandUIExtension xmlns='http://schemas.microsoft.com/sharepoint/'>" +
                    "<CommandUIDefinitions>" +
                    "<CommandUIDefinition Location='Ribbon.Documents.Copies.Controls._children'>" +
                    "<Button Id='SPMultiZipDownloadButton' Command='SPMultiZipDownload.Button' " +
                    "Image32by32='/_layouts/15/images/SPMultiZipDownload/SPMultiZipDownload_32x32.png' " +
                    "Image16by16='/_layouts/15/images/SPMultiZipDownload/SPMultiZipDownload_16x16.png' " +
                    "TemplateAlias='o1' " +
                    "LabelText='" + lableText + "'/>" +
                    "</CommandUIDefinition>" +
                    "</CommandUIDefinitions>" +
                    "<CommandUIHandlers>" +
                    "<CommandUIHandler " +
                    "Command='SPMultiZipDownload.Button' " +
                    "CommandAction=\"javascript:window.open('" + urlToDownloadPage + "','_self');\" " +
                    @"EnabledScript='javascript:var EnableDisable = function() {
                             this.clientContext = SP.ClientContext.get_current();
                             this.selectedItems = SP.ListOperation.Selection.getSelectedItems(this.clientContext);
                             var ci = CountDictionary(selectedItems);
                             return (ci > 0);
                           };
                           EnableDisable();' />" +
                    "</CommandUIHandlers>" +
                    "</CommandUIExtension>";
                customAction.Update();
            }
            catch (Exception ex)
            {
                WriteExToLog(ex);
            }
        }
 public void Update()
 {
     m_userCustomAction.Update();
 }