最近项目遇到一个很麻烦的问题,原以为很容易解决,结果搞了那么久,先开个头,再慢慢写

 

SharePoint 2010 ——自定义上传页面与多文件上传解决方案

1.创建Sharepoint空白项目,创建应用程序页面,创建custom action,

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Description="Customize the upload.aspx file for a document library"
               RegistrationType="List"
                RegistrationId="101"
                GroupId="Permissions"
                Id="05511583-fb44-4eca-817a-45892250da9e"
                Location="Microsoft.SharePoint.ListEdit"
                Sequence="1000"
                Title="Customize Upload Form (TCL SUNJUNLIN)"
                >
    <UrlAction Url="~site/_layouts/Custom.ApplicationPage/SetCustomUploadProperties.aspx?List={ListId}" />
  </CustomAction>
</Elements>

2自定义项目feature.

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;

namespace Custom.ApplicationPage.Features.CustomApp
{
    /// <summary>
    /// 此类用于处理在激活、停用、安装、卸载和升级功能的过程中引发的事件。
    /// </summary>
    /// <remarks>
    /// 附加到此类的 GUID 可能会在打包期间使用,不应进行修改。
    /// </remarks>

    [Guid("a4314576-6717-47fc-909b-8e692f1d32c1")]
    public class CustomAppEventReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            try
            {
                SPWeb web = properties.Feature.Parent as SPWeb;
                web.CustomUploadPage = "/_layouts/Custom.ApplicationPage/CustomUpload.aspx";
                web.Update();
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw;
            }
        }


        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            try
            {
                SPWeb web = properties.Feature.Parent as SPWeb;
                web.CustomUploadPage = "";
                web.Update();
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw;
            }
        }
        public static void LogException(Exception ex)
        {
            if (ex.InnerException != null)
                LogException(ex.InnerException);
            Log(ex.Message, ex.StackTrace);
        }
        public static void Log(string Message, string StackTrace)
        {
            //log to ULS
            SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("TCL.CustomUpload", TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.Unexpected, Message, StackTrace);
        }
    }
}
View Code

相关文章:

  • 2021-05-12
  • 2021-05-24
  • 2021-08-07
  • 2021-08-08
  • 2022-02-23
  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-14
  • 2021-09-10
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
相关资源
相似解决方案